ExpediaOA #5
Get Maximum Efficiency
Estimated MediumJudge-ready
Topics (AI-labelled)Prefix & RangesIn-place Arrays
Choose one activation window [t1,t2] and run every test case that arrives within this closed interval. The efficiency is the number of executed cases minus the duration t2−t1; multiple cases with the same arrival time are all executed, and the answer may be negative.
Input
The first line contains n (2≤n≤200000), and the second line contains n arrival times, 1≤arrivalTime[i]≤1000000000.
Output
Output the maximum efficiency achievable while processing at least two test cases.
Example 1
Input:
5
9 1 3 5 6
Output:
1
Example 2
Input:
3
4 2 1
Output:
1
Example 3
Input:
2
1 1000000000
Output:
-999999997
Editorial
Loading solution…