cswork / OA打开练习工作台

ExpediaOA #5

Get Maximum Efficiency

估计中等可在线判题

考点(AI 标注)前缀和区间原地数组

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.

输入格式

The first line contains n (2≤n≤200000), and the second line contains n arrival times, 1≤arrivalTime[i]≤1000000000.

输出格式

Output the maximum efficiency achievable while processing at least two test cases.

样例 1

输入:

5
9 1 3 5 6

输出:

1

样例 2

输入:

3
4 2 1

输出:

1

样例 3

输入:

2
1 1000000000

输出:

-999999997