답안 #499080

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499080 2021-12-27T08:00:58 Z ismoilov Bigger segments (IZhO19_segments) C++14
100 / 100
78 ms 18916 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
void S()
{
	int n;
	cin >> n;
	vector <int> a(n+1);
	fpp(i,1,n)
		cin >> a[i];
	vector <ll> pr(n+2), b(n+2), d(n+2);
	fpp(i,1,n)
		pr[i] = pr[i-1] + a[i];
	fpp(i,1,n){
		b[i] = max(b[i-1], b[i]);
		d[i] = d[b[i]] + 1;
		ll c = 2*pr[i] - pr[b[i]];
		int x = lower_bound(pr.begin()+1, pr.begin()+1+n, c) - pr.begin();
		b[x] = max(b[x], i*1ll);
	}
	cout << d[n];
}
int main()
{
	IOS;
	S();
}

Compilation message

segments.cpp: In function 'void S()':
segments.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
segments.cpp:15:2: note: in expansion of macro 'fpp'
   15 |  fpp(i,1,n)
      |  ^~~
segments.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
segments.cpp:18:2: note: in expansion of macro 'fpp'
   18 |  fpp(i,1,n)
      |  ^~~
segments.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
segments.cpp:20:2: note: in expansion of macro 'fpp'
   20 |  fpp(i,1,n){
      |  ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 288 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 312 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 0 ms 316 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 1 ms 316 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 288 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 312 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 0 ms 316 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 1 ms 316 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 324 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 2 ms 332 KB Output is correct
38 Correct 1 ms 320 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 320 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 316 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 288 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 312 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 0 ms 316 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 1 ms 316 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 324 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 2 ms 332 KB Output is correct
38 Correct 1 ms 320 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 320 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 316 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 328 KB Output is correct
46 Correct 10 ms 3392 KB Output is correct
47 Correct 13 ms 3504 KB Output is correct
48 Correct 17 ms 3764 KB Output is correct
49 Correct 16 ms 3916 KB Output is correct
50 Correct 16 ms 4024 KB Output is correct
51 Correct 18 ms 3888 KB Output is correct
52 Correct 8 ms 2152 KB Output is correct
53 Correct 5 ms 1356 KB Output is correct
54 Correct 11 ms 3208 KB Output is correct
55 Correct 16 ms 4020 KB Output is correct
56 Correct 12 ms 3492 KB Output is correct
57 Correct 11 ms 3396 KB Output is correct
58 Correct 12 ms 3520 KB Output is correct
59 Correct 15 ms 3636 KB Output is correct
60 Correct 14 ms 3620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 288 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 312 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 0 ms 316 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 1 ms 316 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 324 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 2 ms 332 KB Output is correct
38 Correct 1 ms 320 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 320 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 316 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 328 KB Output is correct
46 Correct 10 ms 3392 KB Output is correct
47 Correct 13 ms 3504 KB Output is correct
48 Correct 17 ms 3764 KB Output is correct
49 Correct 16 ms 3916 KB Output is correct
50 Correct 16 ms 4024 KB Output is correct
51 Correct 18 ms 3888 KB Output is correct
52 Correct 8 ms 2152 KB Output is correct
53 Correct 5 ms 1356 KB Output is correct
54 Correct 11 ms 3208 KB Output is correct
55 Correct 16 ms 4020 KB Output is correct
56 Correct 12 ms 3492 KB Output is correct
57 Correct 11 ms 3396 KB Output is correct
58 Correct 12 ms 3520 KB Output is correct
59 Correct 15 ms 3636 KB Output is correct
60 Correct 14 ms 3620 KB Output is correct
61 Correct 50 ms 15948 KB Output is correct
62 Correct 49 ms 15940 KB Output is correct
63 Correct 62 ms 16324 KB Output is correct
64 Correct 78 ms 18500 KB Output is correct
65 Correct 76 ms 18916 KB Output is correct
66 Correct 77 ms 18764 KB Output is correct
67 Correct 61 ms 15052 KB Output is correct
68 Correct 35 ms 7616 KB Output is correct
69 Correct 55 ms 15056 KB Output is correct
70 Correct 75 ms 18888 KB Output is correct
71 Correct 62 ms 15964 KB Output is correct
72 Correct 59 ms 16332 KB Output is correct
73 Correct 62 ms 16852 KB Output is correct
74 Correct 67 ms 17212 KB Output is correct
75 Correct 68 ms 17232 KB Output is correct