Submit | All submissions | Best solutions | Back to list |
MAXINARR - Maximum element of an array |
Given an array of n integers, find the value of its maximum element.
Input
The input consists of several test cases.
Each test case is described in two lines. The first line contains n, the size of the array (1 <= n <= 106). The second line contains n integers separated by one or more spaces. Each integer in the array will be between -109 and 109, inclusive.
The last line of the input contains a single 0 and should not be processed.
Output
For each test case, write the maximum element in the array on a single line.
Example
Input: 4 1 2 3 4 2 -1 0 3 -1000000000 0 1000000000 0 Output: 4 0 1000000000
Added by: | Andrés Mejía-Posada |
Date: | 2012-03-12 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Introduction to Programming Course, EAFIT University |
hide comments
|
|||||
2012-03-13 05:22:21 Nnavneetsinha
please fix the input files according to problem statement. Last edit: 2012-03-13 04:00:50 |
|||||
2012-03-13 05:22:21 Gaurav Kumar Verma
my o/p is correct but i m getting tle plz hlp. |
|||||
2012-03-13 05:22:21 hibernating
stl inbuilt function gives AC but why the recursive approach is giving TLE.... |
|||||
2012-03-13 05:22:21 hibernating
(3/2)*n-2 gives tle.... |
|||||
2012-03-13 05:22:21 anshul garg
my program is giving correct o/p within time limit(O(n)) solution but TLE is shown |
|||||
2012-03-13 05:22:21 Mitch Schwartz
Something wrong with the input file. I got AC when I assumed that the final 0 is not necessarily there. Also, tutorial. |
|||||
2012-03-13 05:22:21 Devil D
O(n) giving TLE ... |