AmazonOA #138
Dropped Requests
估计中等可在线判题
Requests are given in non-decreasing time order. At most 3 per second, at most 20 in the latest 10 seconds including the current second, and at most 60 in the latest 60 seconds; a request exceeding any limit is dropped and counted only once. Requests already dropped still count toward later statistics.
输入格式
The first line contains n (1..1000000), and the second line contains n non-decreasing times (1..10^9). The 10-second window is [T−9,T] and the 60-second window is [T−59,T], with endpoints included.
输出格式
Output a single integer answer.
样例 1
输入:
5
1 1 1 1 2
输出:
1
样例 2
输入:
21
1 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7
输出:
2
样例 3
输入:
61
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
输出:
0
样例说明
Example 1: the 4th request in the same second is dropped, so the answer is 1. Example 2: the 4th in the same second and the 21st within 10 seconds are each dropped, so the answer is 2. Example 3: every 60-second span has at most exactly 60, so all are accepted and the answer is 0.