# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1064619 |
2024-08-18T15:46:14 Z |
aufan |
Money (IZhO17_money) |
C++17 |
|
147 ms |
30680 KB |
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) cin >> a[i];
vector<int> fen(1000001);
auto upd = [&](int x, int val) {
for (; x <= 1000000; x += x & -x) fen[x] += val;
};
auto qry = [&](int x) {
int res = 0;
for (; x > 0; x -= x & -x) res += fen[x];
return res;
};
int j = 1;
vector<int> dp(n + 1);
for (int i = 1; i <= n; i++) {
if (a[i] < a[i - 1]) {
while (j < i) {
upd(a[j++], 1);
}
}
while (j < i && qry(a[i] - 1) - qry(a[j]) > 0) {
upd(a[j++], 1);
}
dp[i] = dp[j - 1] + 1;
}
cout << dp[n] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8280 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8284 KB |
Output is correct |
4 |
Correct |
2 ms |
8060 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
2 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8228 KB |
Output is correct |
10 |
Correct |
1 ms |
8280 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
1 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 ms |
8212 KB |
Output is correct |
15 |
Correct |
2 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8280 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8284 KB |
Output is correct |
4 |
Correct |
2 ms |
8060 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
2 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8228 KB |
Output is correct |
10 |
Correct |
1 ms |
8280 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
1 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 ms |
8212 KB |
Output is correct |
15 |
Correct |
2 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8284 KB |
Output is correct |
17 |
Correct |
3 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8184 KB |
Output is correct |
19 |
Correct |
3 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8284 KB |
Output is correct |
21 |
Correct |
5 ms |
8144 KB |
Output is correct |
22 |
Correct |
1 ms |
8284 KB |
Output is correct |
23 |
Correct |
4 ms |
8284 KB |
Output is correct |
24 |
Correct |
3 ms |
8284 KB |
Output is correct |
25 |
Correct |
1 ms |
8136 KB |
Output is correct |
26 |
Correct |
2 ms |
8284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8280 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8284 KB |
Output is correct |
4 |
Correct |
2 ms |
8060 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
2 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8228 KB |
Output is correct |
10 |
Correct |
1 ms |
8280 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
1 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 ms |
8212 KB |
Output is correct |
15 |
Correct |
2 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8284 KB |
Output is correct |
17 |
Correct |
3 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8184 KB |
Output is correct |
19 |
Correct |
3 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8284 KB |
Output is correct |
21 |
Correct |
5 ms |
8144 KB |
Output is correct |
22 |
Correct |
1 ms |
8284 KB |
Output is correct |
23 |
Correct |
4 ms |
8284 KB |
Output is correct |
24 |
Correct |
3 ms |
8284 KB |
Output is correct |
25 |
Correct |
1 ms |
8136 KB |
Output is correct |
26 |
Correct |
2 ms |
8284 KB |
Output is correct |
27 |
Correct |
3 ms |
8284 KB |
Output is correct |
28 |
Correct |
1 ms |
8284 KB |
Output is correct |
29 |
Correct |
3 ms |
8284 KB |
Output is correct |
30 |
Correct |
1 ms |
8284 KB |
Output is correct |
31 |
Correct |
2 ms |
8284 KB |
Output is correct |
32 |
Correct |
1 ms |
8284 KB |
Output is correct |
33 |
Correct |
2 ms |
8284 KB |
Output is correct |
34 |
Correct |
2 ms |
8284 KB |
Output is correct |
35 |
Correct |
2 ms |
8280 KB |
Output is correct |
36 |
Correct |
1 ms |
8284 KB |
Output is correct |
37 |
Correct |
2 ms |
8284 KB |
Output is correct |
38 |
Correct |
2 ms |
8284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8280 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8284 KB |
Output is correct |
4 |
Correct |
2 ms |
8060 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
2 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8228 KB |
Output is correct |
10 |
Correct |
1 ms |
8280 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
1 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 ms |
8212 KB |
Output is correct |
15 |
Correct |
2 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8284 KB |
Output is correct |
17 |
Correct |
3 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8184 KB |
Output is correct |
19 |
Correct |
3 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8284 KB |
Output is correct |
21 |
Correct |
5 ms |
8144 KB |
Output is correct |
22 |
Correct |
1 ms |
8284 KB |
Output is correct |
23 |
Correct |
4 ms |
8284 KB |
Output is correct |
24 |
Correct |
3 ms |
8284 KB |
Output is correct |
25 |
Correct |
1 ms |
8136 KB |
Output is correct |
26 |
Correct |
2 ms |
8284 KB |
Output is correct |
27 |
Correct |
3 ms |
8284 KB |
Output is correct |
28 |
Correct |
1 ms |
8284 KB |
Output is correct |
29 |
Correct |
3 ms |
8284 KB |
Output is correct |
30 |
Correct |
1 ms |
8284 KB |
Output is correct |
31 |
Correct |
2 ms |
8284 KB |
Output is correct |
32 |
Correct |
1 ms |
8284 KB |
Output is correct |
33 |
Correct |
2 ms |
8284 KB |
Output is correct |
34 |
Correct |
2 ms |
8284 KB |
Output is correct |
35 |
Correct |
2 ms |
8280 KB |
Output is correct |
36 |
Correct |
1 ms |
8284 KB |
Output is correct |
37 |
Correct |
2 ms |
8284 KB |
Output is correct |
38 |
Correct |
2 ms |
8284 KB |
Output is correct |
39 |
Correct |
50 ms |
18808 KB |
Output is correct |
40 |
Correct |
95 ms |
25936 KB |
Output is correct |
41 |
Correct |
47 ms |
16732 KB |
Output is correct |
42 |
Correct |
45 ms |
15956 KB |
Output is correct |
43 |
Correct |
31 ms |
13660 KB |
Output is correct |
44 |
Correct |
131 ms |
30544 KB |
Output is correct |
45 |
Correct |
111 ms |
30420 KB |
Output is correct |
46 |
Correct |
110 ms |
30548 KB |
Output is correct |
47 |
Correct |
142 ms |
30548 KB |
Output is correct |
48 |
Correct |
107 ms |
30548 KB |
Output is correct |
49 |
Correct |
147 ms |
30540 KB |
Output is correct |
50 |
Correct |
125 ms |
30540 KB |
Output is correct |
51 |
Correct |
122 ms |
30560 KB |
Output is correct |
52 |
Correct |
115 ms |
30528 KB |
Output is correct |
53 |
Correct |
134 ms |
30668 KB |
Output is correct |
54 |
Correct |
121 ms |
30428 KB |
Output is correct |
55 |
Correct |
130 ms |
30428 KB |
Output is correct |
56 |
Correct |
129 ms |
30556 KB |
Output is correct |
57 |
Correct |
137 ms |
30680 KB |
Output is correct |
58 |
Correct |
137 ms |
30548 KB |
Output is correct |
59 |
Correct |
123 ms |
30672 KB |
Output is correct |
60 |
Correct |
128 ms |
30672 KB |
Output is correct |
61 |
Correct |
128 ms |
30536 KB |
Output is correct |
62 |
Correct |
129 ms |
30668 KB |
Output is correct |