#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44
using namespace std;
const int MAXN = (int) 1e6;
int arr[MAXN + 1];
int aib[MAXN + 1];
inline void update(int pos, int n) {
for(int i = pos; i <= MAXN; i += lsb(i)) {
aib[i]++;
}
}
inline int query(int pos) {
int ans = 0;
for(int i = pos; i > 0; i -= lsb(i)) {
ans += aib[i];
}
return ans;
}
inline int sum(int l, int r) {
if(l == r) {
return 0;
}
return query(r - 1) - query(l);
}
int main() {
//ifstream cin("A.in");
//ofstream cout("A.out");
int i, n;
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n;
for(i = 1; i <= n; i++) {
cin >> arr[i];
}
int ans = 0;
i = 1;
while(i <= n) {
int j = i + 1;
ans++;
while(j <= n && arr[j] >= arr[j - 1] && sum(arr[i], arr[j]) == 0) {
j++;
}
while(i < j) {
update(arr[i], n);
i++;
}
}
cout << ans;
//cin.close();
//cout.close();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
532 KB |
Output is correct |
3 |
Correct |
2 ms |
532 KB |
Output is correct |
4 |
Correct |
2 ms |
532 KB |
Output is correct |
5 |
Correct |
2 ms |
532 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
604 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
11 |
Correct |
2 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
2 ms |
756 KB |
Output is correct |
14 |
Correct |
2 ms |
756 KB |
Output is correct |
15 |
Correct |
2 ms |
812 KB |
Output is correct |
16 |
Correct |
2 ms |
820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
532 KB |
Output is correct |
3 |
Correct |
2 ms |
532 KB |
Output is correct |
4 |
Correct |
2 ms |
532 KB |
Output is correct |
5 |
Correct |
2 ms |
532 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
604 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
11 |
Correct |
2 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
2 ms |
756 KB |
Output is correct |
14 |
Correct |
2 ms |
756 KB |
Output is correct |
15 |
Correct |
2 ms |
812 KB |
Output is correct |
16 |
Correct |
2 ms |
820 KB |
Output is correct |
17 |
Correct |
2 ms |
820 KB |
Output is correct |
18 |
Correct |
2 ms |
828 KB |
Output is correct |
19 |
Correct |
2 ms |
828 KB |
Output is correct |
20 |
Correct |
2 ms |
836 KB |
Output is correct |
21 |
Correct |
2 ms |
892 KB |
Output is correct |
22 |
Correct |
2 ms |
892 KB |
Output is correct |
23 |
Correct |
2 ms |
892 KB |
Output is correct |
24 |
Correct |
2 ms |
892 KB |
Output is correct |
25 |
Correct |
2 ms |
892 KB |
Output is correct |
26 |
Correct |
2 ms |
892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
532 KB |
Output is correct |
3 |
Correct |
2 ms |
532 KB |
Output is correct |
4 |
Correct |
2 ms |
532 KB |
Output is correct |
5 |
Correct |
2 ms |
532 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
604 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
11 |
Correct |
2 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
2 ms |
756 KB |
Output is correct |
14 |
Correct |
2 ms |
756 KB |
Output is correct |
15 |
Correct |
2 ms |
812 KB |
Output is correct |
16 |
Correct |
2 ms |
820 KB |
Output is correct |
17 |
Correct |
2 ms |
820 KB |
Output is correct |
18 |
Correct |
2 ms |
828 KB |
Output is correct |
19 |
Correct |
2 ms |
828 KB |
Output is correct |
20 |
Correct |
2 ms |
836 KB |
Output is correct |
21 |
Correct |
2 ms |
892 KB |
Output is correct |
22 |
Correct |
2 ms |
892 KB |
Output is correct |
23 |
Correct |
2 ms |
892 KB |
Output is correct |
24 |
Correct |
2 ms |
892 KB |
Output is correct |
25 |
Correct |
2 ms |
892 KB |
Output is correct |
26 |
Correct |
2 ms |
892 KB |
Output is correct |
27 |
Correct |
2 ms |
892 KB |
Output is correct |
28 |
Correct |
2 ms |
892 KB |
Output is correct |
29 |
Correct |
2 ms |
892 KB |
Output is correct |
30 |
Correct |
2 ms |
892 KB |
Output is correct |
31 |
Correct |
2 ms |
892 KB |
Output is correct |
32 |
Correct |
2 ms |
916 KB |
Output is correct |
33 |
Correct |
2 ms |
916 KB |
Output is correct |
34 |
Correct |
2 ms |
1052 KB |
Output is correct |
35 |
Correct |
1 ms |
1052 KB |
Output is correct |
36 |
Correct |
2 ms |
1052 KB |
Output is correct |
37 |
Correct |
3 ms |
1960 KB |
Output is correct |
38 |
Correct |
3 ms |
2092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
532 KB |
Output is correct |
3 |
Correct |
2 ms |
532 KB |
Output is correct |
4 |
Correct |
2 ms |
532 KB |
Output is correct |
5 |
Correct |
2 ms |
532 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
604 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
11 |
Correct |
2 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
2 ms |
756 KB |
Output is correct |
14 |
Correct |
2 ms |
756 KB |
Output is correct |
15 |
Correct |
2 ms |
812 KB |
Output is correct |
16 |
Correct |
2 ms |
820 KB |
Output is correct |
17 |
Correct |
2 ms |
820 KB |
Output is correct |
18 |
Correct |
2 ms |
828 KB |
Output is correct |
19 |
Correct |
2 ms |
828 KB |
Output is correct |
20 |
Correct |
2 ms |
836 KB |
Output is correct |
21 |
Correct |
2 ms |
892 KB |
Output is correct |
22 |
Correct |
2 ms |
892 KB |
Output is correct |
23 |
Correct |
2 ms |
892 KB |
Output is correct |
24 |
Correct |
2 ms |
892 KB |
Output is correct |
25 |
Correct |
2 ms |
892 KB |
Output is correct |
26 |
Correct |
2 ms |
892 KB |
Output is correct |
27 |
Correct |
2 ms |
892 KB |
Output is correct |
28 |
Correct |
2 ms |
892 KB |
Output is correct |
29 |
Correct |
2 ms |
892 KB |
Output is correct |
30 |
Correct |
2 ms |
892 KB |
Output is correct |
31 |
Correct |
2 ms |
892 KB |
Output is correct |
32 |
Correct |
2 ms |
916 KB |
Output is correct |
33 |
Correct |
2 ms |
916 KB |
Output is correct |
34 |
Correct |
2 ms |
1052 KB |
Output is correct |
35 |
Correct |
1 ms |
1052 KB |
Output is correct |
36 |
Correct |
2 ms |
1052 KB |
Output is correct |
37 |
Correct |
3 ms |
1960 KB |
Output is correct |
38 |
Correct |
3 ms |
2092 KB |
Output is correct |
39 |
Correct |
63 ms |
5936 KB |
Output is correct |
40 |
Correct |
104 ms |
12636 KB |
Output is correct |
41 |
Correct |
53 ms |
13460 KB |
Output is correct |
42 |
Correct |
47 ms |
15784 KB |
Output is correct |
43 |
Correct |
33 ms |
17088 KB |
Output is correct |
44 |
Correct |
131 ms |
26700 KB |
Output is correct |
45 |
Correct |
127 ms |
33336 KB |
Output is correct |
46 |
Correct |
129 ms |
40308 KB |
Output is correct |
47 |
Correct |
119 ms |
47052 KB |
Output is correct |
48 |
Correct |
126 ms |
53932 KB |
Output is correct |
49 |
Correct |
144 ms |
64556 KB |
Output is correct |
50 |
Correct |
147 ms |
71608 KB |
Output is correct |
51 |
Correct |
142 ms |
78040 KB |
Output is correct |
52 |
Correct |
146 ms |
85016 KB |
Output is correct |
53 |
Correct |
145 ms |
91684 KB |
Output is correct |
54 |
Correct |
152 ms |
98356 KB |
Output is correct |
55 |
Correct |
161 ms |
105012 KB |
Output is correct |
56 |
Correct |
152 ms |
111736 KB |
Output is correct |
57 |
Correct |
153 ms |
118516 KB |
Output is correct |
58 |
Correct |
158 ms |
125376 KB |
Output is correct |
59 |
Correct |
154 ms |
132092 KB |
Output is correct |
60 |
Correct |
151 ms |
138732 KB |
Output is correct |
61 |
Correct |
159 ms |
145188 KB |
Output is correct |
62 |
Correct |
165 ms |
151976 KB |
Output is correct |