Submit | All submissions | Best solutions | Back to list |
EIUMADIS - Find the maximum difference |
Given an integer array whose length is n. Find the maximum value of aj – ai for all 0 ≤ i ≤ j < n.
Input
- The first line contains an integer n representing the number of elements in the array (1 ≤ n ≤ 105).
- The second line contains n integers which are elements of the array (|ai| ≤ 2*109).
Output
An only integer which is the maximum difference.
Sample
Input |
Output |
5 2 4 1 5 3 |
4 |
6 10 5 4 3 2 1 |
0 |
Added by: | Ha Minh Ngoc |
Date: | 2018-01-14 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |