# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
420836 |
2021-06-08T14:17:29 Z |
HappyPacMan |
Cigle (COI21_cigle) |
C++14 |
|
3 ms |
2764 KB |
#include <bits/stdc++.h>
using namespace std;
const int MXN = 5005;
int dp[MXN][MXN];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
int arr[N];
for(int i=0;i<N;i++) cin >> arr[i];
int res = 0;
for(int i=1;i<N;i++){
int pref[i];
pref[0] = dp[0][i-1];
for(int j=1;j<i;j++) pref[j] = max(pref[j-1],dp[j][i-1]);
int l=0,r=0,lst=i-1,cost=0;
for(int j=i,k=i-1;j<N;j++){
dp[i][j] = pref[lst] + cost;
l += arr[j];
if(k >= 0 && r+arr[k] <= l) r += arr[k--];
if(l == r && k >= 0){
cost++,lst=k;
r += arr[k--];
}
}
for(int j=i+1;j<N;j++) dp[i][j] = max(dp[i][j-1],dp[i][j]);
for(int j=0;j<N;j++) res = max(res,dp[i][j]);
}
cout << res << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |