답안 #341433

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341433 2020-12-29T16:50:23 Z wwdd Bigger segments (IZhO19_segments) C++14
100 / 100
200 ms 67940 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
vector<map<ll,ll> > go;
vl w,pr;
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	ll n;
	cin >> n;
	go.assign(n+1,map<ll,ll>());
	pr.push_back(0);
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		w.push_back(t);
		pr.push_back(pr.back()+w.back());
	}
	go[1][1] = pr[1];
	for(int i=1;i<=n;i++) {
		while(go[i].size() > 1) {
			go[i].erase(go[i].begin());
		}
		ll num = go[i].begin()->first;
		ll ko = go[i].begin()->second;
		int nx = lower_bound(pr.begin(),pr.end(),pr[i]+ko)-pr.begin();
		if(nx <= n) {
			if(go[nx].count(num+1)) {
				go[nx][num+1] = min(go[nx][num+1],pr[nx]-pr[i]);
			} else {
				go[nx][num+1] = pr[nx]-pr[i];
			}
		}
		if(i+1 <= n) {
			if(go[i+1].count(num)) {
				go[i+1][num] = min(go[i+1][num],ko+pr[i+1]-pr[i]);
			} else {
				go[i+1][num] = ko+pr[i+1]-pr[i];
			}
		}
	}
	cout << go[n].begin()->first << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 2 ms 748 KB Output is correct
32 Correct 1 ms 748 KB Output is correct
33 Correct 2 ms 748 KB Output is correct
34 Correct 1 ms 748 KB Output is correct
35 Correct 2 ms 748 KB Output is correct
36 Correct 2 ms 748 KB Output is correct
37 Correct 2 ms 748 KB Output is correct
38 Correct 1 ms 620 KB Output is correct
39 Correct 1 ms 748 KB Output is correct
40 Correct 2 ms 748 KB Output is correct
41 Correct 2 ms 748 KB Output is correct
42 Correct 2 ms 748 KB Output is correct
43 Correct 2 ms 876 KB Output is correct
44 Correct 2 ms 748 KB Output is correct
45 Correct 2 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 2 ms 748 KB Output is correct
32 Correct 1 ms 748 KB Output is correct
33 Correct 2 ms 748 KB Output is correct
34 Correct 1 ms 748 KB Output is correct
35 Correct 2 ms 748 KB Output is correct
36 Correct 2 ms 748 KB Output is correct
37 Correct 2 ms 748 KB Output is correct
38 Correct 1 ms 620 KB Output is correct
39 Correct 1 ms 748 KB Output is correct
40 Correct 2 ms 748 KB Output is correct
41 Correct 2 ms 748 KB Output is correct
42 Correct 2 ms 748 KB Output is correct
43 Correct 2 ms 876 KB Output is correct
44 Correct 2 ms 748 KB Output is correct
45 Correct 2 ms 748 KB Output is correct
46 Correct 25 ms 13272 KB Output is correct
47 Correct 29 ms 13400 KB Output is correct
48 Correct 35 ms 13656 KB Output is correct
49 Correct 37 ms 13784 KB Output is correct
50 Correct 41 ms 14060 KB Output is correct
51 Correct 35 ms 14040 KB Output is correct
52 Correct 18 ms 7136 KB Output is correct
53 Correct 11 ms 4456 KB Output is correct
54 Correct 30 ms 13016 KB Output is correct
55 Correct 35 ms 13784 KB Output is correct
56 Correct 33 ms 13400 KB Output is correct
57 Correct 32 ms 13272 KB Output is correct
58 Correct 31 ms 13272 KB Output is correct
59 Correct 35 ms 13400 KB Output is correct
60 Correct 39 ms 13400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 2 ms 748 KB Output is correct
32 Correct 1 ms 748 KB Output is correct
33 Correct 2 ms 748 KB Output is correct
34 Correct 1 ms 748 KB Output is correct
35 Correct 2 ms 748 KB Output is correct
36 Correct 2 ms 748 KB Output is correct
37 Correct 2 ms 748 KB Output is correct
38 Correct 1 ms 620 KB Output is correct
39 Correct 1 ms 748 KB Output is correct
40 Correct 2 ms 748 KB Output is correct
41 Correct 2 ms 748 KB Output is correct
42 Correct 2 ms 748 KB Output is correct
43 Correct 2 ms 876 KB Output is correct
44 Correct 2 ms 748 KB Output is correct
45 Correct 2 ms 748 KB Output is correct
46 Correct 25 ms 13272 KB Output is correct
47 Correct 29 ms 13400 KB Output is correct
48 Correct 35 ms 13656 KB Output is correct
49 Correct 37 ms 13784 KB Output is correct
50 Correct 41 ms 14060 KB Output is correct
51 Correct 35 ms 14040 KB Output is correct
52 Correct 18 ms 7136 KB Output is correct
53 Correct 11 ms 4456 KB Output is correct
54 Correct 30 ms 13016 KB Output is correct
55 Correct 35 ms 13784 KB Output is correct
56 Correct 33 ms 13400 KB Output is correct
57 Correct 32 ms 13272 KB Output is correct
58 Correct 31 ms 13272 KB Output is correct
59 Correct 35 ms 13400 KB Output is correct
60 Correct 39 ms 13400 KB Output is correct
61 Correct 123 ms 64956 KB Output is correct
62 Correct 127 ms 64996 KB Output is correct
63 Correct 148 ms 65340 KB Output is correct
64 Correct 200 ms 67516 KB Output is correct
65 Correct 200 ms 67900 KB Output is correct
66 Correct 180 ms 67772 KB Output is correct
67 Correct 136 ms 54340 KB Output is correct
68 Correct 68 ms 27340 KB Output is correct
69 Correct 146 ms 63972 KB Output is correct
70 Correct 182 ms 67940 KB Output is correct
71 Correct 159 ms 64956 KB Output is correct
72 Correct 151 ms 65340 KB Output is correct
73 Correct 179 ms 65956 KB Output is correct
74 Correct 172 ms 66384 KB Output is correct
75 Correct 174 ms 66364 KB Output is correct