# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1116257 |
2024-11-21T11:41:59 Z |
epicci23 |
Cigle (COI21_cigle) |
C++17 |
|
7 ms |
4600 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 pre[n+5][n+5],dp[n+5][n+5];
memset(dp,0,sizeof(dp));
memset(pre,0,sizeof(pre));
for(int i = 1; i <= n; i++){
int p = i, cur = 0, cost = 0, _p = i - 1, cur2 = 0;
while(p <= n){
while(_p > 1 && cur2 < cur) cur2 += ar[_p--];
if(cur > 0 && cur == cur2) cost++;
cur += ar[p];
// cout << i << ' ' << p << ' ' << cost << '\n';
dp[i][p] = max(dp[i][p], pre[_p][i-1] + cost);
p++;
}
for(int j = 1; j <= i; j++) pre[j][i] = max(pre[j-1][i], dp[j][i]);
}
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 |
504 KB |
Output is correct |
8 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
504 KB |
Output is correct |
8 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4600 KB |
Output is correct |
2 |
Correct |
5 ms |
4600 KB |
Output is correct |
3 |
Correct |
5 ms |
4432 KB |
Output is correct |
4 |
Correct |
5 ms |
4448 KB |
Output is correct |
5 |
Correct |
5 ms |
4432 KB |
Output is correct |
6 |
Incorrect |
5 ms |
4432 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
504 KB |
Output is correct |
8 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
504 KB |
Output is correct |
8 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |