# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1116226 |
2024-11-21T11:02:42 Z |
epicci23 |
Cigle (COI21_cigle) |
C++17 |
|
1000 ms |
196680 KB |
#include "bits/stdc++.h"
#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
void _(){
int n; cin >> n;
int ar[n+5];
for(int i=1;i<=n;i++) cin >> ar[i];
int dp[n+5][n+5];
memset(dp,0,sizeof(dp));
for(int i=1;i<=n;i++){
for(int j=i;j<=n;j++){
// last block starts from right to left
vector<int> s;
int sum = 0;
for(int z = j; z > i; z--){
sum += ar[z];
s.push_back(sum);
}
int p = j + 1, cur = 0, cost = 0;
int _p = 0;
while(p <= n){
while(_p < sz(s) && s[_p] < cur) _p++;
if(_p < sz(s) && s[_p] == cur) cost++;
cur += ar[p];
dp[j+1][p] = max(dp[j+1][p], dp[i][j] + cost);
p++;
}
// last block starts from left to right
}
}
int ans = 0;
for(int i=1;i<=n;i++) ans = max(ans, dp[i][n]);
cout << ans << '\n';
}
int32_t main(){
cin.tie(0); ios::sync_with_stdio(0);
int tc=1;//cin >> tc;
while(tc--) _();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
2 ms |
508 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
2556 KB |
Output is correct |
2 |
Correct |
83 ms |
2384 KB |
Output is correct |
3 |
Correct |
83 ms |
2384 KB |
Output is correct |
4 |
Correct |
97 ms |
2384 KB |
Output is correct |
5 |
Correct |
85 ms |
2384 KB |
Output is correct |
6 |
Correct |
103 ms |
2448 KB |
Output is correct |
7 |
Correct |
102 ms |
2384 KB |
Output is correct |
8 |
Correct |
100 ms |
2384 KB |
Output is correct |
9 |
Correct |
100 ms |
2632 KB |
Output is correct |
10 |
Correct |
81 ms |
2552 KB |
Output is correct |
11 |
Correct |
87 ms |
2384 KB |
Output is correct |
12 |
Correct |
82 ms |
2384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
2 ms |
508 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
85 ms |
2556 KB |
Output is correct |
22 |
Correct |
83 ms |
2384 KB |
Output is correct |
23 |
Correct |
83 ms |
2384 KB |
Output is correct |
24 |
Correct |
97 ms |
2384 KB |
Output is correct |
25 |
Correct |
85 ms |
2384 KB |
Output is correct |
26 |
Correct |
103 ms |
2448 KB |
Output is correct |
27 |
Correct |
102 ms |
2384 KB |
Output is correct |
28 |
Correct |
100 ms |
2384 KB |
Output is correct |
29 |
Correct |
100 ms |
2632 KB |
Output is correct |
30 |
Correct |
81 ms |
2552 KB |
Output is correct |
31 |
Correct |
87 ms |
2384 KB |
Output is correct |
32 |
Correct |
82 ms |
2384 KB |
Output is correct |
33 |
Correct |
80 ms |
2384 KB |
Output is correct |
34 |
Correct |
80 ms |
2384 KB |
Output is correct |
35 |
Correct |
88 ms |
2632 KB |
Output is correct |
36 |
Correct |
82 ms |
2384 KB |
Output is correct |
37 |
Correct |
98 ms |
2384 KB |
Output is correct |
38 |
Correct |
101 ms |
2384 KB |
Output is correct |
39 |
Correct |
129 ms |
2400 KB |
Output is correct |
40 |
Correct |
127 ms |
2384 KB |
Output is correct |
41 |
Correct |
110 ms |
2384 KB |
Output is correct |
42 |
Correct |
98 ms |
2384 KB |
Output is correct |
43 |
Correct |
113 ms |
2384 KB |
Output is correct |
44 |
Correct |
113 ms |
2384 KB |
Output is correct |
45 |
Correct |
95 ms |
2384 KB |
Output is correct |
46 |
Correct |
94 ms |
2384 KB |
Output is correct |
47 |
Correct |
116 ms |
2384 KB |
Output is correct |
48 |
Correct |
91 ms |
2552 KB |
Output is correct |
49 |
Correct |
92 ms |
2552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
2 ms |
508 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
85 ms |
2556 KB |
Output is correct |
22 |
Correct |
83 ms |
2384 KB |
Output is correct |
23 |
Correct |
83 ms |
2384 KB |
Output is correct |
24 |
Correct |
97 ms |
2384 KB |
Output is correct |
25 |
Correct |
85 ms |
2384 KB |
Output is correct |
26 |
Correct |
103 ms |
2448 KB |
Output is correct |
27 |
Correct |
102 ms |
2384 KB |
Output is correct |
28 |
Correct |
100 ms |
2384 KB |
Output is correct |
29 |
Correct |
100 ms |
2632 KB |
Output is correct |
30 |
Correct |
81 ms |
2552 KB |
Output is correct |
31 |
Correct |
87 ms |
2384 KB |
Output is correct |
32 |
Correct |
82 ms |
2384 KB |
Output is correct |
33 |
Correct |
80 ms |
2384 KB |
Output is correct |
34 |
Correct |
80 ms |
2384 KB |
Output is correct |
35 |
Correct |
88 ms |
2632 KB |
Output is correct |
36 |
Correct |
82 ms |
2384 KB |
Output is correct |
37 |
Correct |
98 ms |
2384 KB |
Output is correct |
38 |
Correct |
101 ms |
2384 KB |
Output is correct |
39 |
Correct |
129 ms |
2400 KB |
Output is correct |
40 |
Correct |
127 ms |
2384 KB |
Output is correct |
41 |
Correct |
110 ms |
2384 KB |
Output is correct |
42 |
Correct |
98 ms |
2384 KB |
Output is correct |
43 |
Correct |
113 ms |
2384 KB |
Output is correct |
44 |
Correct |
113 ms |
2384 KB |
Output is correct |
45 |
Correct |
95 ms |
2384 KB |
Output is correct |
46 |
Correct |
94 ms |
2384 KB |
Output is correct |
47 |
Correct |
116 ms |
2384 KB |
Output is correct |
48 |
Correct |
91 ms |
2552 KB |
Output is correct |
49 |
Correct |
92 ms |
2552 KB |
Output is correct |
50 |
Execution timed out |
1048 ms |
196680 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |