# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
36950 |
2017-12-19T14:40:29 Z |
nickyrio |
Money (IZhO17_money) |
C++14 |
|
223 ms |
9836 KB |
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<=b ; i++)
#define FORD(i, a, b) for (int i = a; i>=b; i--)
#define REP(i, a) for (int i = 0; i<a; i++)
#define N 1001000
#define pp pair<int, int>
#define IO cin.tie(NULL);cout.tie(NULL);
#define bit(S, i) (((S) >> i) & 1)
template<typename T> inline void read(T &x) {
char c;
bool neg = false;
while (!isdigit(c = getchar()) && c != '-');
x = 0;
if (c == '-') {
neg = true;
c = getchar();
}
do {
x = x * 10 + c - '0';
} while (isdigit(c = getchar()));
if (neg) x = -x;
}
template<typename T> inline void write(T x) {
if (x < 0) {
putchar('-');
write(-x);return;
}
if (x < 10) {
putchar(char(x + 48));
}
else {
write(x/10);
putchar(char(48 + x%10));
}
}
template<typename T> inline void writeln(T x) {
write(x);
putchar('\n');
}
using namespace std;
int n, a[N];
set<int> used;
int BIT[N];
void Up(int u, int val) {
for(; u > 0; u -= u & -u) BIT[u] = min(BIT[u], val);
}
int Get(int u) {
int ans = 1e9;
for(; u < N ; u += u & -u) ans = min(ans, BIT[u]);
return ans;
}
int main() {
IO;
read(n);
FOR(i, 1, n) read(a[i]);
FOR(i, 1, N - 1) BIT[i] = 1e9;
int start = 1;
int cnt = 0;
while (start <= n) {
cnt++;
int last = start + 1;
Up(a[start], a[start]);
int lim = Get(a[start] + 1);
// cerr << lim << ' ';
while (last <= n && a[last] <= lim && a[last] >= a[last - 1]) {
Up(a[last], a[last]); last++;
}
start = last;
}
writeln(cnt);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9836 KB |
Output is correct |
2 |
Correct |
0 ms |
9836 KB |
Output is correct |
3 |
Correct |
0 ms |
9836 KB |
Output is correct |
4 |
Correct |
0 ms |
9836 KB |
Output is correct |
5 |
Correct |
0 ms |
9836 KB |
Output is correct |
6 |
Correct |
0 ms |
9836 KB |
Output is correct |
7 |
Correct |
0 ms |
9836 KB |
Output is correct |
8 |
Correct |
0 ms |
9836 KB |
Output is correct |
9 |
Correct |
0 ms |
9836 KB |
Output is correct |
10 |
Correct |
0 ms |
9836 KB |
Output is correct |
11 |
Correct |
0 ms |
9836 KB |
Output is correct |
12 |
Correct |
3 ms |
9836 KB |
Output is correct |
13 |
Correct |
0 ms |
9836 KB |
Output is correct |
14 |
Correct |
0 ms |
9836 KB |
Output is correct |
15 |
Correct |
0 ms |
9836 KB |
Output is correct |
16 |
Correct |
0 ms |
9836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9836 KB |
Output is correct |
2 |
Correct |
0 ms |
9836 KB |
Output is correct |
3 |
Correct |
0 ms |
9836 KB |
Output is correct |
4 |
Correct |
0 ms |
9836 KB |
Output is correct |
5 |
Correct |
0 ms |
9836 KB |
Output is correct |
6 |
Correct |
0 ms |
9836 KB |
Output is correct |
7 |
Correct |
0 ms |
9836 KB |
Output is correct |
8 |
Correct |
0 ms |
9836 KB |
Output is correct |
9 |
Correct |
0 ms |
9836 KB |
Output is correct |
10 |
Correct |
0 ms |
9836 KB |
Output is correct |
11 |
Correct |
0 ms |
9836 KB |
Output is correct |
12 |
Correct |
3 ms |
9836 KB |
Output is correct |
13 |
Correct |
0 ms |
9836 KB |
Output is correct |
14 |
Correct |
0 ms |
9836 KB |
Output is correct |
15 |
Correct |
0 ms |
9836 KB |
Output is correct |
16 |
Correct |
0 ms |
9836 KB |
Output is correct |
17 |
Correct |
3 ms |
9836 KB |
Output is correct |
18 |
Correct |
3 ms |
9836 KB |
Output is correct |
19 |
Correct |
0 ms |
9836 KB |
Output is correct |
20 |
Correct |
0 ms |
9836 KB |
Output is correct |
21 |
Correct |
0 ms |
9836 KB |
Output is correct |
22 |
Correct |
0 ms |
9836 KB |
Output is correct |
23 |
Correct |
3 ms |
9836 KB |
Output is correct |
24 |
Correct |
3 ms |
9836 KB |
Output is correct |
25 |
Correct |
0 ms |
9836 KB |
Output is correct |
26 |
Correct |
3 ms |
9836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9836 KB |
Output is correct |
2 |
Correct |
0 ms |
9836 KB |
Output is correct |
3 |
Correct |
0 ms |
9836 KB |
Output is correct |
4 |
Correct |
0 ms |
9836 KB |
Output is correct |
5 |
Correct |
0 ms |
9836 KB |
Output is correct |
6 |
Correct |
0 ms |
9836 KB |
Output is correct |
7 |
Correct |
0 ms |
9836 KB |
Output is correct |
8 |
Correct |
0 ms |
9836 KB |
Output is correct |
9 |
Correct |
0 ms |
9836 KB |
Output is correct |
10 |
Correct |
0 ms |
9836 KB |
Output is correct |
11 |
Correct |
0 ms |
9836 KB |
Output is correct |
12 |
Correct |
3 ms |
9836 KB |
Output is correct |
13 |
Correct |
0 ms |
9836 KB |
Output is correct |
14 |
Correct |
0 ms |
9836 KB |
Output is correct |
15 |
Correct |
0 ms |
9836 KB |
Output is correct |
16 |
Correct |
0 ms |
9836 KB |
Output is correct |
17 |
Correct |
3 ms |
9836 KB |
Output is correct |
18 |
Correct |
3 ms |
9836 KB |
Output is correct |
19 |
Correct |
0 ms |
9836 KB |
Output is correct |
20 |
Correct |
0 ms |
9836 KB |
Output is correct |
21 |
Correct |
0 ms |
9836 KB |
Output is correct |
22 |
Correct |
0 ms |
9836 KB |
Output is correct |
23 |
Correct |
3 ms |
9836 KB |
Output is correct |
24 |
Correct |
3 ms |
9836 KB |
Output is correct |
25 |
Correct |
0 ms |
9836 KB |
Output is correct |
26 |
Correct |
3 ms |
9836 KB |
Output is correct |
27 |
Correct |
0 ms |
9836 KB |
Output is correct |
28 |
Correct |
0 ms |
9836 KB |
Output is correct |
29 |
Correct |
0 ms |
9836 KB |
Output is correct |
30 |
Correct |
3 ms |
9836 KB |
Output is correct |
31 |
Correct |
0 ms |
9836 KB |
Output is correct |
32 |
Correct |
0 ms |
9836 KB |
Output is correct |
33 |
Correct |
0 ms |
9836 KB |
Output is correct |
34 |
Correct |
0 ms |
9836 KB |
Output is correct |
35 |
Correct |
0 ms |
9836 KB |
Output is correct |
36 |
Correct |
3 ms |
9836 KB |
Output is correct |
37 |
Correct |
3 ms |
9836 KB |
Output is correct |
38 |
Correct |
3 ms |
9836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9836 KB |
Output is correct |
2 |
Correct |
0 ms |
9836 KB |
Output is correct |
3 |
Correct |
0 ms |
9836 KB |
Output is correct |
4 |
Correct |
0 ms |
9836 KB |
Output is correct |
5 |
Correct |
0 ms |
9836 KB |
Output is correct |
6 |
Correct |
0 ms |
9836 KB |
Output is correct |
7 |
Correct |
0 ms |
9836 KB |
Output is correct |
8 |
Correct |
0 ms |
9836 KB |
Output is correct |
9 |
Correct |
0 ms |
9836 KB |
Output is correct |
10 |
Correct |
0 ms |
9836 KB |
Output is correct |
11 |
Correct |
0 ms |
9836 KB |
Output is correct |
12 |
Correct |
3 ms |
9836 KB |
Output is correct |
13 |
Correct |
0 ms |
9836 KB |
Output is correct |
14 |
Correct |
0 ms |
9836 KB |
Output is correct |
15 |
Correct |
0 ms |
9836 KB |
Output is correct |
16 |
Correct |
0 ms |
9836 KB |
Output is correct |
17 |
Correct |
3 ms |
9836 KB |
Output is correct |
18 |
Correct |
3 ms |
9836 KB |
Output is correct |
19 |
Correct |
0 ms |
9836 KB |
Output is correct |
20 |
Correct |
0 ms |
9836 KB |
Output is correct |
21 |
Correct |
0 ms |
9836 KB |
Output is correct |
22 |
Correct |
0 ms |
9836 KB |
Output is correct |
23 |
Correct |
3 ms |
9836 KB |
Output is correct |
24 |
Correct |
3 ms |
9836 KB |
Output is correct |
25 |
Correct |
0 ms |
9836 KB |
Output is correct |
26 |
Correct |
3 ms |
9836 KB |
Output is correct |
27 |
Correct |
0 ms |
9836 KB |
Output is correct |
28 |
Correct |
0 ms |
9836 KB |
Output is correct |
29 |
Correct |
0 ms |
9836 KB |
Output is correct |
30 |
Correct |
3 ms |
9836 KB |
Output is correct |
31 |
Correct |
0 ms |
9836 KB |
Output is correct |
32 |
Correct |
0 ms |
9836 KB |
Output is correct |
33 |
Correct |
0 ms |
9836 KB |
Output is correct |
34 |
Correct |
0 ms |
9836 KB |
Output is correct |
35 |
Correct |
0 ms |
9836 KB |
Output is correct |
36 |
Correct |
3 ms |
9836 KB |
Output is correct |
37 |
Correct |
3 ms |
9836 KB |
Output is correct |
38 |
Correct |
3 ms |
9836 KB |
Output is correct |
39 |
Correct |
53 ms |
9836 KB |
Output is correct |
40 |
Correct |
103 ms |
9836 KB |
Output is correct |
41 |
Correct |
46 ms |
9836 KB |
Output is correct |
42 |
Correct |
46 ms |
9836 KB |
Output is correct |
43 |
Correct |
39 ms |
9836 KB |
Output is correct |
44 |
Correct |
129 ms |
9836 KB |
Output is correct |
45 |
Correct |
139 ms |
9836 KB |
Output is correct |
46 |
Correct |
163 ms |
9836 KB |
Output is correct |
47 |
Correct |
126 ms |
9836 KB |
Output is correct |
48 |
Correct |
143 ms |
9836 KB |
Output is correct |
49 |
Correct |
179 ms |
9836 KB |
Output is correct |
50 |
Correct |
166 ms |
9836 KB |
Output is correct |
51 |
Correct |
163 ms |
9836 KB |
Output is correct |
52 |
Correct |
176 ms |
9836 KB |
Output is correct |
53 |
Correct |
139 ms |
9836 KB |
Output is correct |
54 |
Correct |
186 ms |
9836 KB |
Output is correct |
55 |
Correct |
176 ms |
9836 KB |
Output is correct |
56 |
Correct |
203 ms |
9836 KB |
Output is correct |
57 |
Correct |
183 ms |
9836 KB |
Output is correct |
58 |
Correct |
176 ms |
9836 KB |
Output is correct |
59 |
Correct |
183 ms |
9836 KB |
Output is correct |
60 |
Correct |
169 ms |
9836 KB |
Output is correct |
61 |
Correct |
223 ms |
9836 KB |
Output is correct |
62 |
Correct |
189 ms |
9836 KB |
Output is correct |