# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
386260 | 2021-04-06T08:40:03 Z | patrikpavic2 | Money (IZhO17_money) | C++17 | 1500 ms | 2156 KB |
#include <cstdio> #include <cstring> #include <vector> #include <set> #include <algorithm> #define X first #define Y second #define PB push_back using namespace std; const int N = 1e6 + 500; int A[N], n, prv[N], nxt[N], sol; int cnt[N]; int main(){ scanf("%d", &n); for(int i = 0;i < n;i++){ scanf("%d", A + i); cnt[A[i]]++; } for(int i = n - 1;i >= 0;i--){ cnt[A[i]]--; while(i > 0 && A[i - 1] == A[i]){ i--; cnt[A[i]]--; } int cur = A[i] - 1; while(!cnt[cur] && cur > 0) cur--; if(i > 0 && A[i - 1] == cur){ i--; cnt[A[i]]--; } cur = A[i]; while(!cnt[cur] && cur > 0) cur--; while(i > 0 && A[i - 1] == cur){ i--; cnt[A[i]]--; while(!cnt[cur] && cur > 0) cur--; } sol++; } printf("%d\n", sol); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 3 ms | 364 KB | Output is correct |
8 | Correct | 5 ms | 364 KB | Output is correct |
9 | Correct | 2 ms | 364 KB | Output is correct |
10 | Correct | 5 ms | 364 KB | Output is correct |
11 | Correct | 4 ms | 364 KB | Output is correct |
12 | Correct | 5 ms | 364 KB | Output is correct |
13 | Correct | 5 ms | 364 KB | Output is correct |
14 | Correct | 4 ms | 364 KB | Output is correct |
15 | Correct | 7 ms | 364 KB | Output is correct |
16 | Correct | 8 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 3 ms | 364 KB | Output is correct |
8 | Correct | 5 ms | 364 KB | Output is correct |
9 | Correct | 2 ms | 364 KB | Output is correct |
10 | Correct | 5 ms | 364 KB | Output is correct |
11 | Correct | 4 ms | 364 KB | Output is correct |
12 | Correct | 5 ms | 364 KB | Output is correct |
13 | Correct | 5 ms | 364 KB | Output is correct |
14 | Correct | 4 ms | 364 KB | Output is correct |
15 | Correct | 7 ms | 364 KB | Output is correct |
16 | Correct | 8 ms | 364 KB | Output is correct |
17 | Correct | 6 ms | 364 KB | Output is correct |
18 | Correct | 5 ms | 512 KB | Output is correct |
19 | Correct | 3 ms | 364 KB | Output is correct |
20 | Correct | 6 ms | 364 KB | Output is correct |
21 | Correct | 4 ms | 364 KB | Output is correct |
22 | Correct | 5 ms | 364 KB | Output is correct |
23 | Correct | 5 ms | 364 KB | Output is correct |
24 | Correct | 7 ms | 364 KB | Output is correct |
25 | Correct | 9 ms | 364 KB | Output is correct |
26 | Correct | 10 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 3 ms | 364 KB | Output is correct |
8 | Correct | 5 ms | 364 KB | Output is correct |
9 | Correct | 2 ms | 364 KB | Output is correct |
10 | Correct | 5 ms | 364 KB | Output is correct |
11 | Correct | 4 ms | 364 KB | Output is correct |
12 | Correct | 5 ms | 364 KB | Output is correct |
13 | Correct | 5 ms | 364 KB | Output is correct |
14 | Correct | 4 ms | 364 KB | Output is correct |
15 | Correct | 7 ms | 364 KB | Output is correct |
16 | Correct | 8 ms | 364 KB | Output is correct |
17 | Correct | 6 ms | 364 KB | Output is correct |
18 | Correct | 5 ms | 512 KB | Output is correct |
19 | Correct | 3 ms | 364 KB | Output is correct |
20 | Correct | 6 ms | 364 KB | Output is correct |
21 | Correct | 4 ms | 364 KB | Output is correct |
22 | Correct | 5 ms | 364 KB | Output is correct |
23 | Correct | 5 ms | 364 KB | Output is correct |
24 | Correct | 7 ms | 364 KB | Output is correct |
25 | Correct | 9 ms | 364 KB | Output is correct |
26 | Correct | 10 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 1 ms | 364 KB | Output is correct |
32 | Correct | 45 ms | 364 KB | Output is correct |
33 | Correct | 33 ms | 364 KB | Output is correct |
34 | Correct | 35 ms | 364 KB | Output is correct |
35 | Correct | 13 ms | 364 KB | Output is correct |
36 | Correct | 48 ms | 364 KB | Output is correct |
37 | Correct | 24 ms | 876 KB | Output is correct |
38 | Correct | 27 ms | 876 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 3 ms | 364 KB | Output is correct |
8 | Correct | 5 ms | 364 KB | Output is correct |
9 | Correct | 2 ms | 364 KB | Output is correct |
10 | Correct | 5 ms | 364 KB | Output is correct |
11 | Correct | 4 ms | 364 KB | Output is correct |
12 | Correct | 5 ms | 364 KB | Output is correct |
13 | Correct | 5 ms | 364 KB | Output is correct |
14 | Correct | 4 ms | 364 KB | Output is correct |
15 | Correct | 7 ms | 364 KB | Output is correct |
16 | Correct | 8 ms | 364 KB | Output is correct |
17 | Correct | 6 ms | 364 KB | Output is correct |
18 | Correct | 5 ms | 512 KB | Output is correct |
19 | Correct | 3 ms | 364 KB | Output is correct |
20 | Correct | 6 ms | 364 KB | Output is correct |
21 | Correct | 4 ms | 364 KB | Output is correct |
22 | Correct | 5 ms | 364 KB | Output is correct |
23 | Correct | 5 ms | 364 KB | Output is correct |
24 | Correct | 7 ms | 364 KB | Output is correct |
25 | Correct | 9 ms | 364 KB | Output is correct |
26 | Correct | 10 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 1 ms | 364 KB | Output is correct |
32 | Correct | 45 ms | 364 KB | Output is correct |
33 | Correct | 33 ms | 364 KB | Output is correct |
34 | Correct | 35 ms | 364 KB | Output is correct |
35 | Correct | 13 ms | 364 KB | Output is correct |
36 | Correct | 48 ms | 364 KB | Output is correct |
37 | Correct | 24 ms | 876 KB | Output is correct |
38 | Correct | 27 ms | 876 KB | Output is correct |
39 | Execution timed out | 1583 ms | 2156 KB | Time limit exceeded |
40 | Halted | 0 ms | 0 KB | - |