답안 #75090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
75090 2018-09-08T09:43:21 Z Nordway Money (IZhO17_money) C++14
100 / 100
820 ms 152304 KB
#include<bits/stdc++.h>

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF = 1e18;
const int inf = INT_MAX;
const ll mod = 1e9 + 7;
const int pi = acos(-1);
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int N = 1e6;
const int MAXN = 1e6 + 1;
int t[4 * MAXN], a[MAXN];

void upd(int v, int tl, int tr, int pos){
	if(tl == tr){
		t[v]++;
		return ;
	}
	int tm = (tl + tr) / 2;
	if(pos <= tm)upd(v * 2, tl, tm, pos);
	else upd(v * 2 + 1, tm + 1, tr, pos);
	t[v] = t[v * 2] + t[v * 2 + 1];
}
int get(int v, int tl, int tr, int l, int r){
	if(l > r || tl > r || l > tr)return 0;
	if(l <= tl && tr <= r)return t[v];
	int tm = (tl + tr) / 2;
	return get(v * 2, tl, tm, l, r) + get(v * 2 + 1, tm + 1, tr, l, r);
}


int main(){
	boost;
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	int ans = 0;
	for(int i = 1; i <= n; ){
		int l = i, r = i + 1;
		ans++;
		while(r <= n){
			if(get(1, 1, N, a[l] + 1, a[r] - 1) > 0 || a[r] < a[r - 1])break;
			r++;
		}
		for(int j = l; j < r; j++)upd(1, 1, N, a[j]);
		i = r;
	}
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 528 KB Output is correct
3 Correct 2 ms 528 KB Output is correct
4 Correct 2 ms 528 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 3 ms 528 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 2 ms 824 KB Output is correct
13 Correct 3 ms 824 KB Output is correct
14 Correct 3 ms 824 KB Output is correct
15 Correct 2 ms 824 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 528 KB Output is correct
3 Correct 2 ms 528 KB Output is correct
4 Correct 2 ms 528 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 3 ms 528 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 2 ms 824 KB Output is correct
13 Correct 3 ms 824 KB Output is correct
14 Correct 3 ms 824 KB Output is correct
15 Correct 2 ms 824 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 3 ms 832 KB Output is correct
18 Correct 2 ms 836 KB Output is correct
19 Correct 2 ms 840 KB Output is correct
20 Correct 2 ms 864 KB Output is correct
21 Correct 2 ms 944 KB Output is correct
22 Correct 3 ms 944 KB Output is correct
23 Correct 2 ms 944 KB Output is correct
24 Correct 3 ms 944 KB Output is correct
25 Correct 3 ms 1140 KB Output is correct
26 Correct 3 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 528 KB Output is correct
3 Correct 2 ms 528 KB Output is correct
4 Correct 2 ms 528 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 3 ms 528 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 2 ms 824 KB Output is correct
13 Correct 3 ms 824 KB Output is correct
14 Correct 3 ms 824 KB Output is correct
15 Correct 2 ms 824 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 3 ms 832 KB Output is correct
18 Correct 2 ms 836 KB Output is correct
19 Correct 2 ms 840 KB Output is correct
20 Correct 2 ms 864 KB Output is correct
21 Correct 2 ms 944 KB Output is correct
22 Correct 3 ms 944 KB Output is correct
23 Correct 2 ms 944 KB Output is correct
24 Correct 3 ms 944 KB Output is correct
25 Correct 3 ms 1140 KB Output is correct
26 Correct 3 ms 1272 KB Output is correct
27 Correct 2 ms 1272 KB Output is correct
28 Correct 2 ms 1272 KB Output is correct
29 Correct 3 ms 1272 KB Output is correct
30 Correct 2 ms 1272 KB Output is correct
31 Correct 3 ms 1272 KB Output is correct
32 Correct 3 ms 1272 KB Output is correct
33 Correct 2 ms 1272 KB Output is correct
34 Correct 2 ms 1272 KB Output is correct
35 Correct 2 ms 1272 KB Output is correct
36 Correct 2 ms 1272 KB Output is correct
37 Correct 5 ms 3356 KB Output is correct
38 Correct 5 ms 3356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 528 KB Output is correct
3 Correct 2 ms 528 KB Output is correct
4 Correct 2 ms 528 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 3 ms 528 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 2 ms 824 KB Output is correct
13 Correct 3 ms 824 KB Output is correct
14 Correct 3 ms 824 KB Output is correct
15 Correct 2 ms 824 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 3 ms 832 KB Output is correct
18 Correct 2 ms 836 KB Output is correct
19 Correct 2 ms 840 KB Output is correct
20 Correct 2 ms 864 KB Output is correct
21 Correct 2 ms 944 KB Output is correct
22 Correct 3 ms 944 KB Output is correct
23 Correct 2 ms 944 KB Output is correct
24 Correct 3 ms 944 KB Output is correct
25 Correct 3 ms 1140 KB Output is correct
26 Correct 3 ms 1272 KB Output is correct
27 Correct 2 ms 1272 KB Output is correct
28 Correct 2 ms 1272 KB Output is correct
29 Correct 3 ms 1272 KB Output is correct
30 Correct 2 ms 1272 KB Output is correct
31 Correct 3 ms 1272 KB Output is correct
32 Correct 3 ms 1272 KB Output is correct
33 Correct 2 ms 1272 KB Output is correct
34 Correct 2 ms 1272 KB Output is correct
35 Correct 2 ms 1272 KB Output is correct
36 Correct 2 ms 1272 KB Output is correct
37 Correct 5 ms 3356 KB Output is correct
38 Correct 5 ms 3356 KB Output is correct
39 Correct 154 ms 6248 KB Output is correct
40 Correct 277 ms 12892 KB Output is correct
41 Correct 130 ms 13804 KB Output is correct
42 Correct 196 ms 16112 KB Output is correct
43 Correct 86 ms 17544 KB Output is correct
44 Correct 360 ms 26900 KB Output is correct
45 Correct 390 ms 33504 KB Output is correct
46 Correct 362 ms 40436 KB Output is correct
47 Correct 315 ms 47032 KB Output is correct
48 Correct 325 ms 54140 KB Output is correct
49 Correct 597 ms 68920 KB Output is correct
50 Correct 567 ms 75724 KB Output is correct
51 Correct 553 ms 82452 KB Output is correct
52 Correct 547 ms 89256 KB Output is correct
53 Correct 545 ms 95932 KB Output is correct
54 Correct 560 ms 102756 KB Output is correct
55 Correct 740 ms 109428 KB Output is correct
56 Correct 820 ms 116160 KB Output is correct
57 Correct 747 ms 122900 KB Output is correct
58 Correct 749 ms 129584 KB Output is correct
59 Correct 793 ms 133852 KB Output is correct
60 Correct 745 ms 140588 KB Output is correct
61 Correct 803 ms 145448 KB Output is correct
62 Correct 747 ms 152304 KB Output is correct