Submission #523715

# Submission time Handle Problem Language Result Execution time Memory
523715 2022-02-08T04:52:08 Z Sanzhar23 Money (IZhO17_money) C++14
100 / 100
144 ms 14968 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long	
#define pb push_back
#define bug cout << "bug" << endl
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pll pair <ll, ll> 
#define pii pair <int, int> 
#define triple pair <pair <ll, ll> , ll>  
#define ull unsigned long long
#define ld long double
#define pinode pair <node*, node*>

const ll INF = 9e18 + 5;
const ll inf = 1e9 + 5;
const ll N = 1e6 + 5;
const ll shift = 2e6;
const ll mod = 1e9 + 7;
const ll M = 255000 + 5;
const ll LOG = 21;
const ll sp = 263;
const ll block = 500;
const double eps = 1e-10;
	
int n, a[N], t[N];

void upd(int pos, int val){
	while(pos <= N - 5){
		t[pos] += val;
		pos = (pos | (pos + 1));
	}
}

int get(int pos){
	int res = 0;
	while(pos >= 0){
		res += t[pos];
		pos = (pos & (pos + 1)) - 1;
	}
	return res;
}

int sum(int l, int r){
	if(l > r)
		return 0;
	return get(r) - get(l - 1);
}

int main(){
    speed;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int st = 1, ans = 0;
	while(st <= n){
		int nw = st + 1;
		ans++;
		for(int i = st + 1; i <= n; i++){
			if(a[i] >= a[i - 1] && sum(a[st] + 1, a[i] - 1) == 0){
				nw = i + 1;
				continue;
			}
			break;
		}
		for(int i = st; i <= nw - 1; i++)
			upd(a[i], 1);
		st = nw;
	}
	cout << ans << endl;
}
/*	
%I64d

6
3 5 1 2 4 6

		
		



%I64d
*/ 
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 448 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 460 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 0 ms 448 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 448 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 460 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 0 ms 448 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 316 KB Output is correct
34 Correct 1 ms 460 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 1740 KB Output is correct
38 Correct 1 ms 1732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 448 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 460 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 0 ms 448 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 316 KB Output is correct
34 Correct 1 ms 460 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 1740 KB Output is correct
38 Correct 1 ms 1732 KB Output is correct
39 Correct 52 ms 5376 KB Output is correct
40 Correct 95 ms 8900 KB Output is correct
41 Correct 45 ms 4400 KB Output is correct
42 Correct 47 ms 4252 KB Output is correct
43 Correct 28 ms 3040 KB Output is correct
44 Correct 126 ms 11072 KB Output is correct
45 Correct 116 ms 11088 KB Output is correct
46 Correct 122 ms 11200 KB Output is correct
47 Correct 105 ms 11012 KB Output is correct
48 Correct 118 ms 11192 KB Output is correct
49 Correct 130 ms 14788 KB Output is correct
50 Correct 122 ms 14860 KB Output is correct
51 Correct 127 ms 14784 KB Output is correct
52 Correct 112 ms 14860 KB Output is correct
53 Correct 144 ms 14820 KB Output is correct
54 Correct 120 ms 14740 KB Output is correct
55 Correct 128 ms 14968 KB Output is correct
56 Correct 134 ms 14848 KB Output is correct
57 Correct 125 ms 14848 KB Output is correct
58 Correct 131 ms 14788 KB Output is correct
59 Correct 120 ms 14920 KB Output is correct
60 Correct 128 ms 14844 KB Output is correct
61 Correct 128 ms 14756 KB Output is correct
62 Correct 127 ms 14788 KB Output is correct