Score bar(Contest)
Score bar easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Score bar easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement :
You take part in N quizzes and in the ith quiz you get a score of Qi. Your friends are very competitive with you and they ask you the strength of your quiz scores. Strength of an array is defined as the following:
The maximum growth Qj - Qi (Qj > Qi) between two quizzes i and j such that i < j and there is no quiz k such that i < k < j and Qk > Qi. If there is no such pair of indexes, print -1.
Print the strength of your quiz marks in order to impress your friends. Input First line contains a single integer N, the number of quizzes. The second line contains N space seperated integers Q1, Q2,. , QN the score in each quiz.
Constraints: 1 <= N <= 105 1 <= Qi <= 109 Output Print the strength of your quiz marks. Example Sample Input: 6 7 10 7 2 1 8
Sample Output: 7
Explaination: There is a growth of 7 from Q5 (= 1) to Q6(= 8). There is no growth in the array greater than this.
link: