Submission #344293

# Submission time Handle Problem Language Result Execution time Memory
344293 2021-01-05T12:47:27 Z infertechno2 Money (IZhO17_money) C++14
100 / 100
204 ms 14604 KB
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
 
using namespace std;
using ll = long long;
 
const int N = 1e6+5 , inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7 , P = 6547;
 
int f[N] , a[N];
 
int get(int x) {
	int res = 0;
	for(; x > 0; x&=x+1 , x--) {
		res += f[x];
	}
	return res;
}
 
int get(int l , int r) {
	if(r < l) return 0 ;
	return get(r) - get(l-1);
}
 
void upd(int pos) {
	for(; pos < N; pos |= pos+1) {
		f[pos] ++;
	}
}
 
void solve() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	int ans = 0;
	for(int i = 1; i <= n; i ++) {
		int st = i;
		while(a[i] <= a[i+1] && get(a[st] + 1 , a[i+1] - 1) == 0) {
			i ++;
		}
		for(int j = st; j <= i; j ++) upd(a[j]);
		ans ++;
	}
	cout << ans;
}
/*
5 5 6 5 5
*/
main() {
    ios;
    int tt = 1;
    //cin >> tt;
    while(tt --) {
        solve();
    }
    return 0;
}

Compilation message

money.cpp:56:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   56 | main() {
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 1 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 1 ms 528 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 1 ms 492 KB Output is correct
34 Correct 1 ms 504 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 1516 KB Output is correct
38 Correct 1 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 1 ms 528 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 1 ms 492 KB Output is correct
34 Correct 1 ms 504 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 1516 KB Output is correct
38 Correct 1 ms 1516 KB Output is correct
39 Correct 65 ms 5472 KB Output is correct
40 Correct 111 ms 8980 KB Output is correct
41 Correct 55 ms 4460 KB Output is correct
42 Correct 60 ms 4204 KB Output is correct
43 Correct 34 ms 3180 KB Output is correct
44 Correct 145 ms 9968 KB Output is correct
45 Correct 144 ms 9892 KB Output is correct
46 Correct 157 ms 9836 KB Output is correct
47 Correct 133 ms 9836 KB Output is correct
48 Correct 136 ms 9836 KB Output is correct
49 Correct 148 ms 13676 KB Output is correct
50 Correct 147 ms 13804 KB Output is correct
51 Correct 149 ms 13676 KB Output is correct
52 Correct 148 ms 13676 KB Output is correct
53 Correct 142 ms 13676 KB Output is correct
54 Correct 155 ms 13676 KB Output is correct
55 Correct 204 ms 13676 KB Output is correct
56 Correct 159 ms 14572 KB Output is correct
57 Correct 153 ms 14444 KB Output is correct
58 Correct 156 ms 14500 KB Output is correct
59 Correct 178 ms 14604 KB Output is correct
60 Correct 154 ms 14572 KB Output is correct
61 Correct 157 ms 14444 KB Output is correct
62 Correct 171 ms 14572 KB Output is correct