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
hide comments
Nnavneetsinha:
2012-03-13 05:22:21
please fix the input files according to problem statement. Last edit: 2012-03-13 04:00:50 |
|
Gaurav Kumar Verma:
2012-03-13 05:22:21
my o/p is correct but i m getting tle plz hlp. |
|
hibernating:
2012-03-13 05:22:21
stl inbuilt function gives AC but why the recursive approach is giving TLE.... |
|
hibernating:
2012-03-13 05:22:21
(3/2)*n-2 gives tle.... |
|
anshul garg:
2012-03-13 05:22:21
my program is giving correct o/p within time limit(O(n)) solution
|
|
Mitch Schwartz:
2012-03-13 05:22:21
Something wrong with the input file. I got AC when I assumed that the final 0 is not necessarily there. Also, tutorial. |
|
Devil D:
2012-03-13 05:22:21
O(n) giving TLE ... |
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 |