# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
971680 |
2024-04-29T07:45:35 Z |
LucaIlie |
Cigle (COI21_cigle) |
C++17 |
|
3 ms |
2904 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 5000;
int d[MAX_N + 1], sd[MAX_N + 1], dp[MAX_N + 1][MAX_N + 1];
int main() {
int n;
cin >> n;
for ( int i = 1; i <= n; i++ ) {
cin >> d[i];
sd[i] = sd[i - 1] + d[i];
}
for ( int i = 1; i <= n; i++ ) {
int k = i, c = 0;
for ( int j = i + 1; j <= n; j++ ) {
while ( k > 0 && sd[i] - sd[k] < sd[j] - sd[i] )
k--;
dp[i][j] = max( dp[i][j], dp[k][i] + c );
if ( sd[i] - sd[k] == sd[j] - sd[i] )
c++;
}
for ( int j = i; j <= n; j++ )
dp[i][j] = max( dp[i][j], max( dp[i - 1][j], dp[i][j - 1] ) );
}
int ans = 0;
for ( int i = 0; i <= n; i++ )
ans = max( ans, dp[i][n] );
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2904 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |