cswork / OA打开练习工作台

AmazonOA #96

Count Possible Winners (All About Rewards :)

估计中等可在线判题

考点(AI 标注)贪心调度前缀和区间

The champion gets n points, and the other places get n−1 down to 1 points. Count the participants who, after winning, have a total score at least equal to everyone else's no matter how the others are ranked. Ties for the top are allowed.

输入格式

The first line contains n (1..100000), and the second line contains n initial scores (0..100000).

输出格式

Output a single integer answer.

样例 1

输入:

3
1 3 4

输出:

2

样例 2

输入:

4
5 7 9 11

输出:

1

样例 3

输入:

3
8 10 9

输出:

2

样例说明

Example 1: score 3 wins and gets 6, tying the 6 that score 4 gets in second place, which still counts as the top; score 4 also qualifies, 2 in total. Example 2: only 11 is within 1 of the maximum score, so the answer is 1. Example 3: both 10 and 9 qualify, so the answer is 2.