# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
377075 |
2021-03-12T23:29:51 Z |
ijxjdjd |
Money (IZhO17_money) |
C++14 |
|
255 ms |
33964 KB |
#include <bits/stdc++.h>
#define FR(i, N) for (int i = 0; i < int(N); i++)
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
multiset<int> lft;
const int MAXN = (int)(1e6);
int arr[MAXN + 5];
int cnt[MAXN+5];
int bk[MAXN+5];
int findLess(int i) {
if (i == -1 || cnt[i] != 0) {
return i;
}
else {
return (bk[i] = findLess(bk[i]));
}
}
int main() {
cin.tie(0);
cin.sync_with_stdio(0);
int N;
// N = (int)(1e6);
cin >> N;
FR(i, N) {
cin >> arr[i];
cnt[arr[i]]++;
// arr[i] = N-i;
}
for (int i = 0; i < MAXN; i++) {
bk[i] = i-1;
}
int lst = arr[N-1];
int ans = 1;
bool ori = true;
for (int i = N-2; i >= 0; i--) {
cnt[arr[i+1]]--;
if (lst == arr[i]) {
}
else {
int f = findLess(lst-1);
if (f == arr[i]) {
if (cnt[lst]) {
if (ori) {
ori = false;
}
else {
ans++;
ori = true;
}
}
else {
ori = false;
}
}
else {
ans++;
ori = true;
}
}
lst = arr[i];
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4204 KB |
Output is correct |
2 |
Correct |
3 ms |
4204 KB |
Output is correct |
3 |
Correct |
3 ms |
4204 KB |
Output is correct |
4 |
Correct |
3 ms |
4204 KB |
Output is correct |
5 |
Correct |
3 ms |
4204 KB |
Output is correct |
6 |
Correct |
3 ms |
4224 KB |
Output is correct |
7 |
Correct |
11 ms |
11940 KB |
Output is correct |
8 |
Correct |
24 ms |
26732 KB |
Output is correct |
9 |
Correct |
17 ms |
17260 KB |
Output is correct |
10 |
Correct |
17 ms |
12908 KB |
Output is correct |
11 |
Correct |
9 ms |
9324 KB |
Output is correct |
12 |
Correct |
16 ms |
13932 KB |
Output is correct |
13 |
Correct |
29 ms |
22508 KB |
Output is correct |
14 |
Correct |
19 ms |
19692 KB |
Output is correct |
15 |
Correct |
20 ms |
15724 KB |
Output is correct |
16 |
Correct |
19 ms |
15468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4204 KB |
Output is correct |
2 |
Correct |
3 ms |
4204 KB |
Output is correct |
3 |
Correct |
3 ms |
4204 KB |
Output is correct |
4 |
Correct |
3 ms |
4204 KB |
Output is correct |
5 |
Correct |
3 ms |
4204 KB |
Output is correct |
6 |
Correct |
3 ms |
4224 KB |
Output is correct |
7 |
Correct |
11 ms |
11940 KB |
Output is correct |
8 |
Correct |
24 ms |
26732 KB |
Output is correct |
9 |
Correct |
17 ms |
17260 KB |
Output is correct |
10 |
Correct |
17 ms |
12908 KB |
Output is correct |
11 |
Correct |
9 ms |
9324 KB |
Output is correct |
12 |
Correct |
16 ms |
13932 KB |
Output is correct |
13 |
Correct |
29 ms |
22508 KB |
Output is correct |
14 |
Correct |
19 ms |
19692 KB |
Output is correct |
15 |
Correct |
20 ms |
15724 KB |
Output is correct |
16 |
Correct |
19 ms |
15468 KB |
Output is correct |
17 |
Correct |
20 ms |
16492 KB |
Output is correct |
18 |
Correct |
24 ms |
17900 KB |
Output is correct |
19 |
Correct |
17 ms |
12396 KB |
Output is correct |
20 |
Correct |
25 ms |
19052 KB |
Output is correct |
21 |
Correct |
15 ms |
11372 KB |
Output is correct |
22 |
Correct |
25 ms |
20204 KB |
Output is correct |
23 |
Correct |
25 ms |
24428 KB |
Output is correct |
24 |
Correct |
19 ms |
15596 KB |
Output is correct |
25 |
Correct |
15 ms |
12524 KB |
Output is correct |
26 |
Correct |
18 ms |
13164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4204 KB |
Output is correct |
2 |
Correct |
3 ms |
4204 KB |
Output is correct |
3 |
Correct |
3 ms |
4204 KB |
Output is correct |
4 |
Correct |
3 ms |
4204 KB |
Output is correct |
5 |
Correct |
3 ms |
4204 KB |
Output is correct |
6 |
Correct |
3 ms |
4224 KB |
Output is correct |
7 |
Correct |
11 ms |
11940 KB |
Output is correct |
8 |
Correct |
24 ms |
26732 KB |
Output is correct |
9 |
Correct |
17 ms |
17260 KB |
Output is correct |
10 |
Correct |
17 ms |
12908 KB |
Output is correct |
11 |
Correct |
9 ms |
9324 KB |
Output is correct |
12 |
Correct |
16 ms |
13932 KB |
Output is correct |
13 |
Correct |
29 ms |
22508 KB |
Output is correct |
14 |
Correct |
19 ms |
19692 KB |
Output is correct |
15 |
Correct |
20 ms |
15724 KB |
Output is correct |
16 |
Correct |
19 ms |
15468 KB |
Output is correct |
17 |
Correct |
20 ms |
16492 KB |
Output is correct |
18 |
Correct |
24 ms |
17900 KB |
Output is correct |
19 |
Correct |
17 ms |
12396 KB |
Output is correct |
20 |
Correct |
25 ms |
19052 KB |
Output is correct |
21 |
Correct |
15 ms |
11372 KB |
Output is correct |
22 |
Correct |
25 ms |
20204 KB |
Output is correct |
23 |
Correct |
25 ms |
24428 KB |
Output is correct |
24 |
Correct |
19 ms |
15596 KB |
Output is correct |
25 |
Correct |
15 ms |
12524 KB |
Output is correct |
26 |
Correct |
18 ms |
13164 KB |
Output is correct |
27 |
Correct |
3 ms |
4204 KB |
Output is correct |
28 |
Correct |
3 ms |
4204 KB |
Output is correct |
29 |
Correct |
3 ms |
4204 KB |
Output is correct |
30 |
Correct |
3 ms |
4204 KB |
Output is correct |
31 |
Correct |
3 ms |
4204 KB |
Output is correct |
32 |
Correct |
19 ms |
14828 KB |
Output is correct |
33 |
Correct |
15 ms |
13568 KB |
Output is correct |
34 |
Correct |
19 ms |
13548 KB |
Output is correct |
35 |
Correct |
13 ms |
16108 KB |
Output is correct |
36 |
Correct |
22 ms |
21100 KB |
Output is correct |
37 |
Correct |
11 ms |
5996 KB |
Output is correct |
38 |
Correct |
11 ms |
6508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4204 KB |
Output is correct |
2 |
Correct |
3 ms |
4204 KB |
Output is correct |
3 |
Correct |
3 ms |
4204 KB |
Output is correct |
4 |
Correct |
3 ms |
4204 KB |
Output is correct |
5 |
Correct |
3 ms |
4204 KB |
Output is correct |
6 |
Correct |
3 ms |
4224 KB |
Output is correct |
7 |
Correct |
11 ms |
11940 KB |
Output is correct |
8 |
Correct |
24 ms |
26732 KB |
Output is correct |
9 |
Correct |
17 ms |
17260 KB |
Output is correct |
10 |
Correct |
17 ms |
12908 KB |
Output is correct |
11 |
Correct |
9 ms |
9324 KB |
Output is correct |
12 |
Correct |
16 ms |
13932 KB |
Output is correct |
13 |
Correct |
29 ms |
22508 KB |
Output is correct |
14 |
Correct |
19 ms |
19692 KB |
Output is correct |
15 |
Correct |
20 ms |
15724 KB |
Output is correct |
16 |
Correct |
19 ms |
15468 KB |
Output is correct |
17 |
Correct |
20 ms |
16492 KB |
Output is correct |
18 |
Correct |
24 ms |
17900 KB |
Output is correct |
19 |
Correct |
17 ms |
12396 KB |
Output is correct |
20 |
Correct |
25 ms |
19052 KB |
Output is correct |
21 |
Correct |
15 ms |
11372 KB |
Output is correct |
22 |
Correct |
25 ms |
20204 KB |
Output is correct |
23 |
Correct |
25 ms |
24428 KB |
Output is correct |
24 |
Correct |
19 ms |
15596 KB |
Output is correct |
25 |
Correct |
15 ms |
12524 KB |
Output is correct |
26 |
Correct |
18 ms |
13164 KB |
Output is correct |
27 |
Correct |
3 ms |
4204 KB |
Output is correct |
28 |
Correct |
3 ms |
4204 KB |
Output is correct |
29 |
Correct |
3 ms |
4204 KB |
Output is correct |
30 |
Correct |
3 ms |
4204 KB |
Output is correct |
31 |
Correct |
3 ms |
4204 KB |
Output is correct |
32 |
Correct |
19 ms |
14828 KB |
Output is correct |
33 |
Correct |
15 ms |
13568 KB |
Output is correct |
34 |
Correct |
19 ms |
13548 KB |
Output is correct |
35 |
Correct |
13 ms |
16108 KB |
Output is correct |
36 |
Correct |
22 ms |
21100 KB |
Output is correct |
37 |
Correct |
11 ms |
5996 KB |
Output is correct |
38 |
Correct |
11 ms |
6508 KB |
Output is correct |
39 |
Correct |
76 ms |
22764 KB |
Output is correct |
40 |
Correct |
97 ms |
18668 KB |
Output is correct |
41 |
Correct |
63 ms |
25324 KB |
Output is correct |
42 |
Correct |
50 ms |
11500 KB |
Output is correct |
43 |
Correct |
39 ms |
10860 KB |
Output is correct |
44 |
Correct |
127 ms |
15940 KB |
Output is correct |
45 |
Correct |
126 ms |
19840 KB |
Output is correct |
46 |
Correct |
123 ms |
17900 KB |
Output is correct |
47 |
Correct |
142 ms |
33964 KB |
Output is correct |
48 |
Correct |
127 ms |
22892 KB |
Output is correct |
49 |
Correct |
188 ms |
12140 KB |
Output is correct |
50 |
Correct |
188 ms |
12012 KB |
Output is correct |
51 |
Correct |
175 ms |
12140 KB |
Output is correct |
52 |
Correct |
173 ms |
12012 KB |
Output is correct |
53 |
Correct |
176 ms |
12012 KB |
Output is correct |
54 |
Correct |
185 ms |
12140 KB |
Output is correct |
55 |
Correct |
210 ms |
12140 KB |
Output is correct |
56 |
Correct |
239 ms |
18924 KB |
Output is correct |
57 |
Correct |
211 ms |
18924 KB |
Output is correct |
58 |
Correct |
217 ms |
18796 KB |
Output is correct |
59 |
Correct |
255 ms |
18796 KB |
Output is correct |
60 |
Correct |
198 ms |
18908 KB |
Output is correct |
61 |
Correct |
230 ms |
19032 KB |
Output is correct |
62 |
Correct |
214 ms |
19052 KB |
Output is correct |