# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
651073 |
2022-10-17T00:22:55 Z |
Shin |
Money (IZhO17_money) |
C++14 |
|
160 ms |
15032 KB |
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
template <class X, class Y> bool minimize(X &a, Y b) {
if (a > b) return a = b, true;
return false;
}
template <class X, class Y> bool maximize(X &a, Y b) {
if (a < b) return a = b, true;
return false;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n; cin >> n;
vector<int> a(n + 7);
for (int i = 1; i <= n; i ++) {
cin >> a[i];
}
vector<int> f((int) 1e6 + 7);
auto modify = [&](int i, int v) {
for (; i <= (int) 1e6; i += i & -i) {
f[i] += v;
}
};
auto get = [&](int i) {
int res = 0;
for (; i; i -= i & - i) {
res += f[i];
}
return res;
};
int res = 1, last = 0;
vector<int> save;
for (int i = 1; i <= n; i ++) {
save.push_back(a[i]);
if (a[i] < a[i - 1]) {
for (int x: save) {
modify(x, 1);
}
save.clear();
last = a[i];
res ++;
} else
if (a[i] > a[i - 1]) {
if (get(a[i] - 1) - get(last) > 0) {
res ++;
for (int x: save) {
modify(x, 1);
}
save.clear();
last = a[i];
}
}
}
cout << res;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4180 KB |
Output is correct |
2 |
Correct |
3 ms |
4180 KB |
Output is correct |
3 |
Correct |
3 ms |
4160 KB |
Output is correct |
4 |
Correct |
2 ms |
4180 KB |
Output is correct |
5 |
Correct |
2 ms |
4180 KB |
Output is correct |
6 |
Correct |
2 ms |
4180 KB |
Output is correct |
7 |
Correct |
2 ms |
4180 KB |
Output is correct |
8 |
Correct |
3 ms |
4180 KB |
Output is correct |
9 |
Correct |
2 ms |
4180 KB |
Output is correct |
10 |
Correct |
3 ms |
4156 KB |
Output is correct |
11 |
Correct |
3 ms |
4160 KB |
Output is correct |
12 |
Correct |
2 ms |
4180 KB |
Output is correct |
13 |
Correct |
2 ms |
4164 KB |
Output is correct |
14 |
Correct |
2 ms |
4180 KB |
Output is correct |
15 |
Correct |
2 ms |
4180 KB |
Output is correct |
16 |
Correct |
2 ms |
4180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4180 KB |
Output is correct |
2 |
Correct |
3 ms |
4180 KB |
Output is correct |
3 |
Correct |
3 ms |
4160 KB |
Output is correct |
4 |
Correct |
2 ms |
4180 KB |
Output is correct |
5 |
Correct |
2 ms |
4180 KB |
Output is correct |
6 |
Correct |
2 ms |
4180 KB |
Output is correct |
7 |
Correct |
2 ms |
4180 KB |
Output is correct |
8 |
Correct |
3 ms |
4180 KB |
Output is correct |
9 |
Correct |
2 ms |
4180 KB |
Output is correct |
10 |
Correct |
3 ms |
4156 KB |
Output is correct |
11 |
Correct |
3 ms |
4160 KB |
Output is correct |
12 |
Correct |
2 ms |
4180 KB |
Output is correct |
13 |
Correct |
2 ms |
4164 KB |
Output is correct |
14 |
Correct |
2 ms |
4180 KB |
Output is correct |
15 |
Correct |
2 ms |
4180 KB |
Output is correct |
16 |
Correct |
2 ms |
4180 KB |
Output is correct |
17 |
Correct |
2 ms |
4304 KB |
Output is correct |
18 |
Correct |
2 ms |
4180 KB |
Output is correct |
19 |
Correct |
2 ms |
4180 KB |
Output is correct |
20 |
Correct |
2 ms |
4180 KB |
Output is correct |
21 |
Correct |
2 ms |
4164 KB |
Output is correct |
22 |
Correct |
2 ms |
4180 KB |
Output is correct |
23 |
Correct |
2 ms |
4180 KB |
Output is correct |
24 |
Correct |
2 ms |
4180 KB |
Output is correct |
25 |
Correct |
2 ms |
4180 KB |
Output is correct |
26 |
Correct |
2 ms |
4180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4180 KB |
Output is correct |
2 |
Correct |
3 ms |
4180 KB |
Output is correct |
3 |
Correct |
3 ms |
4160 KB |
Output is correct |
4 |
Correct |
2 ms |
4180 KB |
Output is correct |
5 |
Correct |
2 ms |
4180 KB |
Output is correct |
6 |
Correct |
2 ms |
4180 KB |
Output is correct |
7 |
Correct |
2 ms |
4180 KB |
Output is correct |
8 |
Correct |
3 ms |
4180 KB |
Output is correct |
9 |
Correct |
2 ms |
4180 KB |
Output is correct |
10 |
Correct |
3 ms |
4156 KB |
Output is correct |
11 |
Correct |
3 ms |
4160 KB |
Output is correct |
12 |
Correct |
2 ms |
4180 KB |
Output is correct |
13 |
Correct |
2 ms |
4164 KB |
Output is correct |
14 |
Correct |
2 ms |
4180 KB |
Output is correct |
15 |
Correct |
2 ms |
4180 KB |
Output is correct |
16 |
Correct |
2 ms |
4180 KB |
Output is correct |
17 |
Correct |
2 ms |
4304 KB |
Output is correct |
18 |
Correct |
2 ms |
4180 KB |
Output is correct |
19 |
Correct |
2 ms |
4180 KB |
Output is correct |
20 |
Correct |
2 ms |
4180 KB |
Output is correct |
21 |
Correct |
2 ms |
4164 KB |
Output is correct |
22 |
Correct |
2 ms |
4180 KB |
Output is correct |
23 |
Correct |
2 ms |
4180 KB |
Output is correct |
24 |
Correct |
2 ms |
4180 KB |
Output is correct |
25 |
Correct |
2 ms |
4180 KB |
Output is correct |
26 |
Correct |
2 ms |
4180 KB |
Output is correct |
27 |
Correct |
2 ms |
4160 KB |
Output is correct |
28 |
Correct |
3 ms |
4180 KB |
Output is correct |
29 |
Correct |
2 ms |
4180 KB |
Output is correct |
30 |
Correct |
2 ms |
4180 KB |
Output is correct |
31 |
Correct |
2 ms |
4180 KB |
Output is correct |
32 |
Correct |
2 ms |
4160 KB |
Output is correct |
33 |
Correct |
2 ms |
4180 KB |
Output is correct |
34 |
Correct |
2 ms |
4180 KB |
Output is correct |
35 |
Correct |
2 ms |
4180 KB |
Output is correct |
36 |
Correct |
2 ms |
4180 KB |
Output is correct |
37 |
Correct |
2 ms |
4180 KB |
Output is correct |
38 |
Correct |
3 ms |
4256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4180 KB |
Output is correct |
2 |
Correct |
3 ms |
4180 KB |
Output is correct |
3 |
Correct |
3 ms |
4160 KB |
Output is correct |
4 |
Correct |
2 ms |
4180 KB |
Output is correct |
5 |
Correct |
2 ms |
4180 KB |
Output is correct |
6 |
Correct |
2 ms |
4180 KB |
Output is correct |
7 |
Correct |
2 ms |
4180 KB |
Output is correct |
8 |
Correct |
3 ms |
4180 KB |
Output is correct |
9 |
Correct |
2 ms |
4180 KB |
Output is correct |
10 |
Correct |
3 ms |
4156 KB |
Output is correct |
11 |
Correct |
3 ms |
4160 KB |
Output is correct |
12 |
Correct |
2 ms |
4180 KB |
Output is correct |
13 |
Correct |
2 ms |
4164 KB |
Output is correct |
14 |
Correct |
2 ms |
4180 KB |
Output is correct |
15 |
Correct |
2 ms |
4180 KB |
Output is correct |
16 |
Correct |
2 ms |
4180 KB |
Output is correct |
17 |
Correct |
2 ms |
4304 KB |
Output is correct |
18 |
Correct |
2 ms |
4180 KB |
Output is correct |
19 |
Correct |
2 ms |
4180 KB |
Output is correct |
20 |
Correct |
2 ms |
4180 KB |
Output is correct |
21 |
Correct |
2 ms |
4164 KB |
Output is correct |
22 |
Correct |
2 ms |
4180 KB |
Output is correct |
23 |
Correct |
2 ms |
4180 KB |
Output is correct |
24 |
Correct |
2 ms |
4180 KB |
Output is correct |
25 |
Correct |
2 ms |
4180 KB |
Output is correct |
26 |
Correct |
2 ms |
4180 KB |
Output is correct |
27 |
Correct |
2 ms |
4160 KB |
Output is correct |
28 |
Correct |
3 ms |
4180 KB |
Output is correct |
29 |
Correct |
2 ms |
4180 KB |
Output is correct |
30 |
Correct |
2 ms |
4180 KB |
Output is correct |
31 |
Correct |
2 ms |
4180 KB |
Output is correct |
32 |
Correct |
2 ms |
4160 KB |
Output is correct |
33 |
Correct |
2 ms |
4180 KB |
Output is correct |
34 |
Correct |
2 ms |
4180 KB |
Output is correct |
35 |
Correct |
2 ms |
4180 KB |
Output is correct |
36 |
Correct |
2 ms |
4180 KB |
Output is correct |
37 |
Correct |
2 ms |
4180 KB |
Output is correct |
38 |
Correct |
3 ms |
4256 KB |
Output is correct |
39 |
Correct |
57 ms |
9360 KB |
Output is correct |
40 |
Correct |
98 ms |
12620 KB |
Output is correct |
41 |
Correct |
51 ms |
8228 KB |
Output is correct |
42 |
Correct |
56 ms |
7788 KB |
Output is correct |
43 |
Correct |
34 ms |
6760 KB |
Output is correct |
44 |
Correct |
119 ms |
14960 KB |
Output is correct |
45 |
Correct |
126 ms |
14820 KB |
Output is correct |
46 |
Correct |
139 ms |
14956 KB |
Output is correct |
47 |
Correct |
116 ms |
15032 KB |
Output is correct |
48 |
Correct |
107 ms |
14964 KB |
Output is correct |
49 |
Correct |
133 ms |
14932 KB |
Output is correct |
50 |
Correct |
133 ms |
14796 KB |
Output is correct |
51 |
Correct |
141 ms |
14860 KB |
Output is correct |
52 |
Correct |
147 ms |
14848 KB |
Output is correct |
53 |
Correct |
147 ms |
14848 KB |
Output is correct |
54 |
Correct |
139 ms |
14712 KB |
Output is correct |
55 |
Correct |
157 ms |
14796 KB |
Output is correct |
56 |
Correct |
154 ms |
14840 KB |
Output is correct |
57 |
Correct |
157 ms |
14964 KB |
Output is correct |
58 |
Correct |
160 ms |
14872 KB |
Output is correct |
59 |
Correct |
143 ms |
14832 KB |
Output is correct |
60 |
Correct |
148 ms |
14836 KB |
Output is correct |
61 |
Correct |
131 ms |
14832 KB |
Output is correct |
62 |
Correct |
140 ms |
14848 KB |
Output is correct |