답안 #786644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
786644 2023-07-18T10:40:54 Z vqpahmad Money (IZhO17_money) C++14
100 / 100
351 ms 30668 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define endl '\n'
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
const int mod = 1e9 + 7;
const int N = 1e6 + 3;
const ll inf = 1e18;
const int off = (1<<20);
int t[off*2];
int combine(int u,int v){
	return u+v;
}
void update(int i,int u){
	i+=off;
	t[i] = u;
	while (i/=2){
		t[i] = combine(t[i*2],t[i*2+1]);
	}
}
int get(int l, int r, int idx=1, int lo=0, int hi=off){
	if (lo>=r||hi<=l) return 0;
	if (lo>=l&&hi<=r) return t[idx];
	int mi = (lo+hi)/2;
	return combine(get(l,r,idx*2,lo,mi),get(l,r,idx*2+1,mi,hi));
}
int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++){
	    cin >> a[i];
    }
    int ans = 0;
    for (int i=0;i<n;){
	    ans++;
	    int b = i;
	    i++;
	    while (i<n&&a[i]>=a[i-1]&&get(a[b]+1,a[i])==0){
		    i++;
	    }
	    for (int j=b;j<i;j++) update(a[j],1);
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 452 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 456 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 452 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 456 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 468 KB Output is correct
25 Correct 1 ms 712 KB Output is correct
26 Correct 1 ms 708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 452 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 456 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 468 KB Output is correct
25 Correct 1 ms 712 KB Output is correct
26 Correct 1 ms 708 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 0 ms 324 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 596 KB Output is correct
35 Correct 1 ms 328 KB Output is correct
36 Correct 1 ms 452 KB Output is correct
37 Correct 2 ms 3272 KB Output is correct
38 Correct 2 ms 3284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 452 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 456 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 468 KB Output is correct
25 Correct 1 ms 712 KB Output is correct
26 Correct 1 ms 708 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 0 ms 324 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 596 KB Output is correct
35 Correct 1 ms 328 KB Output is correct
36 Correct 1 ms 452 KB Output is correct
37 Correct 2 ms 3272 KB Output is correct
38 Correct 2 ms 3284 KB Output is correct
39 Correct 94 ms 7408 KB Output is correct
40 Correct 150 ms 12240 KB Output is correct
41 Correct 70 ms 6040 KB Output is correct
42 Correct 64 ms 5836 KB Output is correct
43 Correct 46 ms 4400 KB Output is correct
44 Correct 189 ms 15188 KB Output is correct
45 Correct 184 ms 15056 KB Output is correct
46 Correct 189 ms 15316 KB Output is correct
47 Correct 195 ms 15064 KB Output is correct
48 Correct 190 ms 15060 KB Output is correct
49 Correct 254 ms 30556 KB Output is correct
50 Correct 277 ms 30540 KB Output is correct
51 Correct 250 ms 30492 KB Output is correct
52 Correct 244 ms 30616 KB Output is correct
53 Correct 261 ms 30540 KB Output is correct
54 Correct 258 ms 30420 KB Output is correct
55 Correct 313 ms 30544 KB Output is correct
56 Correct 320 ms 30668 KB Output is correct
57 Correct 337 ms 30548 KB Output is correct
58 Correct 310 ms 30548 KB Output is correct
59 Correct 313 ms 30540 KB Output is correct
60 Correct 351 ms 30556 KB Output is correct
61 Correct 308 ms 30544 KB Output is correct
62 Correct 332 ms 30548 KB Output is correct