답안 #525021

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
525021 2022-02-10T13:29:55 Z asliddinaif Bigger segments (IZhO19_segments) C++14
100 / 100
90 ms 24388 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)--)
const int maxx = 1e6;
ll a[maxx], dp[maxx], b[maxx];
vector <ll> pr(maxx);
void S()
{
	int n;
	cin >> n;
	fpp(i,1,n)
		cin >> a[i], pr[i] = pr[i-1] + a[i], b[i] = 1, dp[i] = 1e18;
	fpp(i,1,n){
		b[i] = max(b[i], b[i-1]);
		dp[i] = min(dp[i-1] + a[i], dp[i]);
		auto x = lower_bound(pr.begin()+1, pr.begin()+n+1, dp[i]+pr[i]) - pr.begin();
		b[x] = b[i]+1;
		dp[x] = pr[x] - pr[i];
	//	cout << dp[i] << " " << b[i] << " " << x << "\n";
	}
	cout << b[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:17:2: note: in expansion of macro 'fpp'
   17 |  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:19:2: note: in expansion of macro 'fpp'
   19 |  fpp(i,1,n){
      |  ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Correct 4 ms 8140 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 3 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 4 ms 8140 KB Output is correct
8 Correct 3 ms 8140 KB Output is correct
9 Correct 3 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 4 ms 8140 KB Output is correct
12 Correct 4 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
15 Correct 3 ms 8140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Correct 4 ms 8140 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 3 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 4 ms 8140 KB Output is correct
8 Correct 3 ms 8140 KB Output is correct
9 Correct 3 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 4 ms 8140 KB Output is correct
12 Correct 4 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
15 Correct 3 ms 8140 KB Output is correct
16 Correct 4 ms 8140 KB Output is correct
17 Correct 4 ms 8140 KB Output is correct
18 Correct 4 ms 8140 KB Output is correct
19 Correct 4 ms 8168 KB Output is correct
20 Correct 4 ms 8176 KB Output is correct
21 Correct 4 ms 8172 KB Output is correct
22 Correct 4 ms 8160 KB Output is correct
23 Correct 4 ms 8140 KB Output is correct
24 Correct 3 ms 8140 KB Output is correct
25 Correct 3 ms 8140 KB Output is correct
26 Correct 5 ms 8140 KB Output is correct
27 Correct 4 ms 8140 KB Output is correct
28 Correct 4 ms 8168 KB Output is correct
29 Correct 4 ms 8176 KB Output is correct
30 Correct 4 ms 8172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Correct 4 ms 8140 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 3 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 4 ms 8140 KB Output is correct
8 Correct 3 ms 8140 KB Output is correct
9 Correct 3 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 4 ms 8140 KB Output is correct
12 Correct 4 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
15 Correct 3 ms 8140 KB Output is correct
16 Correct 4 ms 8140 KB Output is correct
17 Correct 4 ms 8140 KB Output is correct
18 Correct 4 ms 8140 KB Output is correct
19 Correct 4 ms 8168 KB Output is correct
20 Correct 4 ms 8176 KB Output is correct
21 Correct 4 ms 8172 KB Output is correct
22 Correct 4 ms 8160 KB Output is correct
23 Correct 4 ms 8140 KB Output is correct
24 Correct 3 ms 8140 KB Output is correct
25 Correct 3 ms 8140 KB Output is correct
26 Correct 5 ms 8140 KB Output is correct
27 Correct 4 ms 8140 KB Output is correct
28 Correct 4 ms 8168 KB Output is correct
29 Correct 4 ms 8176 KB Output is correct
30 Correct 4 ms 8172 KB Output is correct
31 Correct 4 ms 8168 KB Output is correct
32 Correct 4 ms 8180 KB Output is correct
33 Correct 4 ms 8176 KB Output is correct
34 Correct 4 ms 8268 KB Output is correct
35 Correct 5 ms 8180 KB Output is correct
36 Correct 4 ms 8176 KB Output is correct
37 Correct 5 ms 8268 KB Output is correct
38 Correct 5 ms 8180 KB Output is correct
39 Correct 4 ms 8260 KB Output is correct
40 Correct 4 ms 8176 KB Output is correct
41 Correct 4 ms 8140 KB Output is correct
42 Correct 4 ms 8268 KB Output is correct
43 Correct 4 ms 8140 KB Output is correct
44 Correct 4 ms 8140 KB Output is correct
45 Correct 4 ms 8176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Correct 4 ms 8140 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 3 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 4 ms 8140 KB Output is correct
8 Correct 3 ms 8140 KB Output is correct
9 Correct 3 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 4 ms 8140 KB Output is correct
12 Correct 4 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
15 Correct 3 ms 8140 KB Output is correct
16 Correct 4 ms 8140 KB Output is correct
17 Correct 4 ms 8140 KB Output is correct
18 Correct 4 ms 8140 KB Output is correct
19 Correct 4 ms 8168 KB Output is correct
20 Correct 4 ms 8176 KB Output is correct
21 Correct 4 ms 8172 KB Output is correct
22 Correct 4 ms 8160 KB Output is correct
23 Correct 4 ms 8140 KB Output is correct
24 Correct 3 ms 8140 KB Output is correct
25 Correct 3 ms 8140 KB Output is correct
26 Correct 5 ms 8140 KB Output is correct
27 Correct 4 ms 8140 KB Output is correct
28 Correct 4 ms 8168 KB Output is correct
29 Correct 4 ms 8176 KB Output is correct
30 Correct 4 ms 8172 KB Output is correct
31 Correct 4 ms 8168 KB Output is correct
32 Correct 4 ms 8180 KB Output is correct
33 Correct 4 ms 8176 KB Output is correct
34 Correct 4 ms 8268 KB Output is correct
35 Correct 5 ms 8180 KB Output is correct
36 Correct 4 ms 8176 KB Output is correct
37 Correct 5 ms 8268 KB Output is correct
38 Correct 5 ms 8180 KB Output is correct
39 Correct 4 ms 8260 KB Output is correct
40 Correct 4 ms 8176 KB Output is correct
41 Correct 4 ms 8140 KB Output is correct
42 Correct 4 ms 8268 KB Output is correct
43 Correct 4 ms 8140 KB Output is correct
44 Correct 4 ms 8140 KB Output is correct
45 Correct 4 ms 8176 KB Output is correct
46 Correct 13 ms 10872 KB Output is correct
47 Correct 15 ms 10956 KB Output is correct
48 Correct 18 ms 11252 KB Output is correct
49 Correct 20 ms 11428 KB Output is correct
50 Correct 21 ms 11368 KB Output is correct
51 Correct 18 ms 11468 KB Output is correct
52 Correct 13 ms 9804 KB Output is correct
53 Correct 8 ms 9076 KB Output is correct
54 Correct 14 ms 10692 KB Output is correct
55 Correct 19 ms 11384 KB Output is correct
56 Correct 16 ms 10904 KB Output is correct
57 Correct 15 ms 10860 KB Output is correct
58 Correct 15 ms 10956 KB Output is correct
59 Correct 19 ms 11048 KB Output is correct
60 Correct 16 ms 11076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Correct 4 ms 8140 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 3 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 4 ms 8140 KB Output is correct
8 Correct 3 ms 8140 KB Output is correct
9 Correct 3 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 4 ms 8140 KB Output is correct
12 Correct 4 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
15 Correct 3 ms 8140 KB Output is correct
16 Correct 4 ms 8140 KB Output is correct
17 Correct 4 ms 8140 KB Output is correct
18 Correct 4 ms 8140 KB Output is correct
19 Correct 4 ms 8168 KB Output is correct
20 Correct 4 ms 8176 KB Output is correct
21 Correct 4 ms 8172 KB Output is correct
22 Correct 4 ms 8160 KB Output is correct
23 Correct 4 ms 8140 KB Output is correct
24 Correct 3 ms 8140 KB Output is correct
25 Correct 3 ms 8140 KB Output is correct
26 Correct 5 ms 8140 KB Output is correct
27 Correct 4 ms 8140 KB Output is correct
28 Correct 4 ms 8168 KB Output is correct
29 Correct 4 ms 8176 KB Output is correct
30 Correct 4 ms 8172 KB Output is correct
31 Correct 4 ms 8168 KB Output is correct
32 Correct 4 ms 8180 KB Output is correct
33 Correct 4 ms 8176 KB Output is correct
34 Correct 4 ms 8268 KB Output is correct
35 Correct 5 ms 8180 KB Output is correct
36 Correct 4 ms 8176 KB Output is correct
37 Correct 5 ms 8268 KB Output is correct
38 Correct 5 ms 8180 KB Output is correct
39 Correct 4 ms 8260 KB Output is correct
40 Correct 4 ms 8176 KB Output is correct
41 Correct 4 ms 8140 KB Output is correct
42 Correct 4 ms 8268 KB Output is correct
43 Correct 4 ms 8140 KB Output is correct
44 Correct 4 ms 8140 KB Output is correct
45 Correct 4 ms 8176 KB Output is correct
46 Correct 13 ms 10872 KB Output is correct
47 Correct 15 ms 10956 KB Output is correct
48 Correct 18 ms 11252 KB Output is correct
49 Correct 20 ms 11428 KB Output is correct
50 Correct 21 ms 11368 KB Output is correct
51 Correct 18 ms 11468 KB Output is correct
52 Correct 13 ms 9804 KB Output is correct
53 Correct 8 ms 9076 KB Output is correct
54 Correct 14 ms 10692 KB Output is correct
55 Correct 19 ms 11384 KB Output is correct
56 Correct 16 ms 10904 KB Output is correct
57 Correct 15 ms 10860 KB Output is correct
58 Correct 15 ms 10956 KB Output is correct
59 Correct 19 ms 11048 KB Output is correct
60 Correct 16 ms 11076 KB Output is correct
61 Correct 51 ms 21740 KB Output is correct
62 Correct 49 ms 21824 KB Output is correct
63 Correct 66 ms 22148 KB Output is correct
64 Correct 82 ms 24308 KB Output is correct
65 Correct 90 ms 24388 KB Output is correct
66 Correct 87 ms 24304 KB Output is correct
67 Correct 66 ms 21316 KB Output is correct
68 Correct 35 ms 14720 KB Output is correct
69 Correct 55 ms 20928 KB Output is correct
70 Correct 82 ms 24344 KB Output is correct
71 Correct 67 ms 21828 KB Output is correct
72 Correct 60 ms 22212 KB Output is correct
73 Correct 69 ms 22832 KB Output is correct
74 Correct 75 ms 23200 KB Output is correct
75 Correct 73 ms 23148 KB Output is correct