# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
417395 |
2021-06-03T16:15:57 Z |
doowey |
Cigle (COI21_cigle) |
C++14 |
|
249 ms |
67420 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = 5010;
int dp[N][N];
int D[N];
int main(){
fastIO;
int n;
cin >> n;
for(int i = 1; i <= n; i ++ ){
cin >> D[i];
}
int pp;
int cum;
int cur;
int outp = 0;
int dpe;
int val;
int cur_v;
int total;
for(int cut = 2; cut <= n; cut ++ ){
for(int ash = 2; ash <= cut - 1; ash ++ ){
dp[ash][cut - 1] = max(dp[ash][cut - 1], dp[ash-1][cut-1]);
}
cur = 0;
cum = 0;
pp = cut;
dpe = cut - 1;
total = 0;
cur_v = 0;
for(int go = cut; go <= n; go ++ ){
dp[cut][go] = dp[dpe][cut - 1] + cur_v;
if(go == n)
outp = max(outp, dp[cut][go]);
cur += D[go];
while(pp > 1 && cum < cur){
pp --;
cum += D[pp];
}
if(cum == cur){
total ++ ;
if(pp - 1 >= dpe){
cur_v ++ ;
}
else{
if(pp - 1 >= 1 && dp[pp - 1][cut - 1] + total >= dp[dpe][cut - 1] + cur_v){
cur_v = total;
dpe = pp - 1;
}
}
}
}
}
cout << outp << "\n";
return 0;
}
Compilation message
cigle.cpp: In function 'int main()':
cigle.cpp:30:9: warning: unused variable 'val' [-Wunused-variable]
30 | int val;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
11 |
Correct |
1 ms |
588 KB |
Output is correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
14 |
Correct |
1 ms |
588 KB |
Output is correct |
15 |
Correct |
1 ms |
588 KB |
Output is correct |
16 |
Correct |
1 ms |
588 KB |
Output is correct |
17 |
Correct |
1 ms |
588 KB |
Output is correct |
18 |
Correct |
1 ms |
580 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2764 KB |
Output is correct |
2 |
Correct |
3 ms |
2764 KB |
Output is correct |
3 |
Correct |
3 ms |
2764 KB |
Output is correct |
4 |
Correct |
3 ms |
2764 KB |
Output is correct |
5 |
Correct |
3 ms |
2764 KB |
Output is correct |
6 |
Correct |
3 ms |
2764 KB |
Output is correct |
7 |
Correct |
3 ms |
2764 KB |
Output is correct |
8 |
Correct |
3 ms |
2772 KB |
Output is correct |
9 |
Correct |
3 ms |
2764 KB |
Output is correct |
10 |
Correct |
3 ms |
2764 KB |
Output is correct |
11 |
Correct |
3 ms |
2764 KB |
Output is correct |
12 |
Correct |
3 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
11 |
Correct |
1 ms |
588 KB |
Output is correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
14 |
Correct |
1 ms |
588 KB |
Output is correct |
15 |
Correct |
1 ms |
588 KB |
Output is correct |
16 |
Correct |
1 ms |
588 KB |
Output is correct |
17 |
Correct |
1 ms |
588 KB |
Output is correct |
18 |
Correct |
1 ms |
580 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
588 KB |
Output is correct |
21 |
Correct |
3 ms |
2764 KB |
Output is correct |
22 |
Correct |
3 ms |
2764 KB |
Output is correct |
23 |
Correct |
3 ms |
2764 KB |
Output is correct |
24 |
Correct |
3 ms |
2764 KB |
Output is correct |
25 |
Correct |
3 ms |
2764 KB |
Output is correct |
26 |
Correct |
3 ms |
2764 KB |
Output is correct |
27 |
Correct |
3 ms |
2764 KB |
Output is correct |
28 |
Correct |
3 ms |
2772 KB |
Output is correct |
29 |
Correct |
3 ms |
2764 KB |
Output is correct |
30 |
Correct |
3 ms |
2764 KB |
Output is correct |
31 |
Correct |
3 ms |
2764 KB |
Output is correct |
32 |
Correct |
3 ms |
2764 KB |
Output is correct |
33 |
Correct |
3 ms |
2764 KB |
Output is correct |
34 |
Correct |
3 ms |
2764 KB |
Output is correct |
35 |
Correct |
3 ms |
2764 KB |
Output is correct |
36 |
Correct |
4 ms |
2764 KB |
Output is correct |
37 |
Correct |
3 ms |
2764 KB |
Output is correct |
38 |
Correct |
4 ms |
2752 KB |
Output is correct |
39 |
Correct |
3 ms |
2764 KB |
Output is correct |
40 |
Correct |
3 ms |
2764 KB |
Output is correct |
41 |
Correct |
3 ms |
2764 KB |
Output is correct |
42 |
Correct |
3 ms |
2764 KB |
Output is correct |
43 |
Correct |
4 ms |
2764 KB |
Output is correct |
44 |
Correct |
3 ms |
2764 KB |
Output is correct |
45 |
Correct |
3 ms |
2764 KB |
Output is correct |
46 |
Correct |
3 ms |
2764 KB |
Output is correct |
47 |
Correct |
3 ms |
2764 KB |
Output is correct |
48 |
Correct |
3 ms |
2764 KB |
Output is correct |
49 |
Correct |
3 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
11 |
Correct |
1 ms |
588 KB |
Output is correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
14 |
Correct |
1 ms |
588 KB |
Output is correct |
15 |
Correct |
1 ms |
588 KB |
Output is correct |
16 |
Correct |
1 ms |
588 KB |
Output is correct |
17 |
Correct |
1 ms |
588 KB |
Output is correct |
18 |
Correct |
1 ms |
580 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
588 KB |
Output is correct |
21 |
Correct |
3 ms |
2764 KB |
Output is correct |
22 |
Correct |
3 ms |
2764 KB |
Output is correct |
23 |
Correct |
3 ms |
2764 KB |
Output is correct |
24 |
Correct |
3 ms |
2764 KB |
Output is correct |
25 |
Correct |
3 ms |
2764 KB |
Output is correct |
26 |
Correct |
3 ms |
2764 KB |
Output is correct |
27 |
Correct |
3 ms |
2764 KB |
Output is correct |
28 |
Correct |
3 ms |
2772 KB |
Output is correct |
29 |
Correct |
3 ms |
2764 KB |
Output is correct |
30 |
Correct |
3 ms |
2764 KB |
Output is correct |
31 |
Correct |
3 ms |
2764 KB |
Output is correct |
32 |
Correct |
3 ms |
2764 KB |
Output is correct |
33 |
Correct |
3 ms |
2764 KB |
Output is correct |
34 |
Correct |
3 ms |
2764 KB |
Output is correct |
35 |
Correct |
3 ms |
2764 KB |
Output is correct |
36 |
Correct |
4 ms |
2764 KB |
Output is correct |
37 |
Correct |
3 ms |
2764 KB |
Output is correct |
38 |
Correct |
4 ms |
2752 KB |
Output is correct |
39 |
Correct |
3 ms |
2764 KB |
Output is correct |
40 |
Correct |
3 ms |
2764 KB |
Output is correct |
41 |
Correct |
3 ms |
2764 KB |
Output is correct |
42 |
Correct |
3 ms |
2764 KB |
Output is correct |
43 |
Correct |
4 ms |
2764 KB |
Output is correct |
44 |
Correct |
3 ms |
2764 KB |
Output is correct |
45 |
Correct |
3 ms |
2764 KB |
Output is correct |
46 |
Correct |
3 ms |
2764 KB |
Output is correct |
47 |
Correct |
3 ms |
2764 KB |
Output is correct |
48 |
Correct |
3 ms |
2764 KB |
Output is correct |
49 |
Correct |
3 ms |
2764 KB |
Output is correct |
50 |
Correct |
217 ms |
67268 KB |
Output is correct |
51 |
Correct |
217 ms |
67220 KB |
Output is correct |
52 |
Correct |
229 ms |
67208 KB |
Output is correct |
53 |
Correct |
216 ms |
67404 KB |
Output is correct |
54 |
Correct |
210 ms |
67268 KB |
Output is correct |
55 |
Correct |
212 ms |
67316 KB |
Output is correct |
56 |
Correct |
249 ms |
67284 KB |
Output is correct |
57 |
Correct |
249 ms |
67204 KB |
Output is correct |
58 |
Correct |
241 ms |
67268 KB |
Output is correct |
59 |
Correct |
237 ms |
67316 KB |
Output is correct |
60 |
Correct |
232 ms |
67252 KB |
Output is correct |
61 |
Correct |
205 ms |
67296 KB |
Output is correct |
62 |
Correct |
204 ms |
67420 KB |
Output is correct |
63 |
Correct |
194 ms |
67268 KB |
Output is correct |
64 |
Correct |
197 ms |
67312 KB |
Output is correct |
65 |
Correct |
207 ms |
67224 KB |
Output is correct |
66 |
Correct |
199 ms |
67268 KB |
Output is correct |
67 |
Correct |
188 ms |
67320 KB |
Output is correct |
68 |
Correct |
182 ms |
67268 KB |
Output is correct |
69 |
Correct |
192 ms |
67300 KB |
Output is correct |
70 |
Correct |
231 ms |
67316 KB |
Output is correct |
71 |
Correct |
230 ms |
67244 KB |
Output is correct |
72 |
Correct |
223 ms |
67296 KB |
Output is correct |