답안 #52398

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52398 2018-06-25T18:34:17 Z MatheusLealV Money (IZhO17_money) C++17
100 / 100
203 ms 152340 KB
#include <bits/stdc++.h>
#define N 1000050
using namespace std;

int bit[N], v[N], n, ans;

void upd(int x, int v)
{
	x += 2;

	for(int i = x; i < N; i += (i&-i)) bit[i] += v;
}

int query(int x)
{
	x += 2;

	int sum = 0;

	for(int i = x; i > 0; i -= (i&-i)) sum += bit[i];

	return sum;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);

	cin>>n;

	for(int i = 1; i <= n; i++) cin>>v[i];

	for(int i = 1; i <= n; i++)
	{
		int st = i, ant = v[i];

		ans ++;

		while(i <= n and v[i] >= ant)
		{
			int A = min(v[i], v[st] - 1), B = max(v[i], v[st] - 1);

			A ++, B --;

			if(A <= B and query(B) - query(A)) break;

			ant = v[i];

			i ++;
		}

		for(int j = st; j < i; j++) upd(v[j], 1);

		i --;
	}

	cout<<ans<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 2 ms 732 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 2 ms 812 KB Output is correct
14 Correct 2 ms 812 KB Output is correct
15 Correct 2 ms 884 KB Output is correct
16 Correct 2 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 2 ms 732 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 2 ms 812 KB Output is correct
14 Correct 2 ms 812 KB Output is correct
15 Correct 2 ms 884 KB Output is correct
16 Correct 2 ms 1016 KB Output is correct
17 Correct 2 ms 1016 KB Output is correct
18 Correct 2 ms 1016 KB Output is correct
19 Correct 2 ms 1016 KB Output is correct
20 Correct 2 ms 1016 KB Output is correct
21 Correct 2 ms 1016 KB Output is correct
22 Correct 2 ms 1016 KB Output is correct
23 Correct 2 ms 1016 KB Output is correct
24 Correct 2 ms 1016 KB Output is correct
25 Correct 2 ms 1016 KB Output is correct
26 Correct 2 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 2 ms 732 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 2 ms 812 KB Output is correct
14 Correct 2 ms 812 KB Output is correct
15 Correct 2 ms 884 KB Output is correct
16 Correct 2 ms 1016 KB Output is correct
17 Correct 2 ms 1016 KB Output is correct
18 Correct 2 ms 1016 KB Output is correct
19 Correct 2 ms 1016 KB Output is correct
20 Correct 2 ms 1016 KB Output is correct
21 Correct 2 ms 1016 KB Output is correct
22 Correct 2 ms 1016 KB Output is correct
23 Correct 2 ms 1016 KB Output is correct
24 Correct 2 ms 1016 KB Output is correct
25 Correct 2 ms 1016 KB Output is correct
26 Correct 2 ms 1016 KB Output is correct
27 Correct 2 ms 1016 KB Output is correct
28 Correct 2 ms 1016 KB Output is correct
29 Correct 2 ms 1016 KB Output is correct
30 Correct 2 ms 1016 KB Output is correct
31 Correct 2 ms 1016 KB Output is correct
32 Correct 2 ms 1016 KB Output is correct
33 Correct 2 ms 1016 KB Output is correct
34 Correct 2 ms 1016 KB Output is correct
35 Correct 2 ms 1016 KB Output is correct
36 Correct 2 ms 1016 KB Output is correct
37 Correct 4 ms 2272 KB Output is correct
38 Correct 3 ms 2276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 2 ms 732 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 2 ms 812 KB Output is correct
14 Correct 2 ms 812 KB Output is correct
15 Correct 2 ms 884 KB Output is correct
16 Correct 2 ms 1016 KB Output is correct
17 Correct 2 ms 1016 KB Output is correct
18 Correct 2 ms 1016 KB Output is correct
19 Correct 2 ms 1016 KB Output is correct
20 Correct 2 ms 1016 KB Output is correct
21 Correct 2 ms 1016 KB Output is correct
22 Correct 2 ms 1016 KB Output is correct
23 Correct 2 ms 1016 KB Output is correct
24 Correct 2 ms 1016 KB Output is correct
25 Correct 2 ms 1016 KB Output is correct
26 Correct 2 ms 1016 KB Output is correct
27 Correct 2 ms 1016 KB Output is correct
28 Correct 2 ms 1016 KB Output is correct
29 Correct 2 ms 1016 KB Output is correct
30 Correct 2 ms 1016 KB Output is correct
31 Correct 2 ms 1016 KB Output is correct
32 Correct 2 ms 1016 KB Output is correct
33 Correct 2 ms 1016 KB Output is correct
34 Correct 2 ms 1016 KB Output is correct
35 Correct 2 ms 1016 KB Output is correct
36 Correct 2 ms 1016 KB Output is correct
37 Correct 4 ms 2272 KB Output is correct
38 Correct 3 ms 2276 KB Output is correct
39 Correct 78 ms 5984 KB Output is correct
40 Correct 131 ms 12740 KB Output is correct
41 Correct 68 ms 13660 KB Output is correct
42 Correct 59 ms 15840 KB Output is correct
43 Correct 45 ms 17144 KB Output is correct
44 Correct 169 ms 26756 KB Output is correct
45 Correct 167 ms 33488 KB Output is correct
46 Correct 163 ms 40408 KB Output is correct
47 Correct 147 ms 47096 KB Output is correct
48 Correct 154 ms 53884 KB Output is correct
49 Correct 180 ms 64608 KB Output is correct
50 Correct 178 ms 71456 KB Output is correct
51 Correct 182 ms 78172 KB Output is correct
52 Correct 181 ms 84824 KB Output is correct
53 Correct 181 ms 91708 KB Output is correct
54 Correct 180 ms 98380 KB Output is correct
55 Correct 203 ms 105016 KB Output is correct
56 Correct 195 ms 111772 KB Output is correct
57 Correct 199 ms 118520 KB Output is correct
58 Correct 195 ms 125380 KB Output is correct
59 Correct 198 ms 131992 KB Output is correct
60 Correct 196 ms 138800 KB Output is correct
61 Correct 195 ms 145532 KB Output is correct
62 Correct 199 ms 152340 KB Output is correct