#include<bits/stdc++.h>
using namespace std;
const int MAXN=505;
long long dp[MAXN][MAXN];
int a[MAXN];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin >> n;
for(int i=1;i<=n;i++)cin >> a[i];
memset(dp,-1,sizeof(dp));
dp[0][0]=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
long long run=a[i];
for(int k=i-1;k>=0;k--){
if(dp[k][j-1]!=-1 && dp[k][j-1]<=run){
dp[i][j]=run;
break;
}
run+=a[k];
}
}
}
for(int j=n;j>=1;j--){
if(dp[n][j]!=-1){
cout << j << '\n';
break;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2284 KB |
Output is correct |
2 |
Correct |
2 ms |
2284 KB |
Output is correct |
3 |
Correct |
2 ms |
2284 KB |
Output is correct |
4 |
Correct |
2 ms |
2304 KB |
Output is correct |
5 |
Correct |
2 ms |
2284 KB |
Output is correct |
6 |
Correct |
2 ms |
2284 KB |
Output is correct |
7 |
Correct |
2 ms |
2304 KB |
Output is correct |
8 |
Correct |
2 ms |
2284 KB |
Output is correct |
9 |
Correct |
1 ms |
2284 KB |
Output is correct |
10 |
Correct |
1 ms |
2284 KB |
Output is correct |
11 |
Correct |
2 ms |
2284 KB |
Output is correct |
12 |
Correct |
2 ms |
2284 KB |
Output is correct |
13 |
Correct |
2 ms |
2300 KB |
Output is correct |
14 |
Correct |
2 ms |
2428 KB |
Output is correct |
15 |
Correct |
2 ms |
2284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2284 KB |
Output is correct |
2 |
Correct |
2 ms |
2284 KB |
Output is correct |
3 |
Correct |
2 ms |
2284 KB |
Output is correct |
4 |
Correct |
2 ms |
2304 KB |
Output is correct |
5 |
Correct |
2 ms |
2284 KB |
Output is correct |
6 |
Correct |
2 ms |
2284 KB |
Output is correct |
7 |
Correct |
2 ms |
2304 KB |
Output is correct |
8 |
Correct |
2 ms |
2284 KB |
Output is correct |
9 |
Correct |
1 ms |
2284 KB |
Output is correct |
10 |
Correct |
1 ms |
2284 KB |
Output is correct |
11 |
Correct |
2 ms |
2284 KB |
Output is correct |
12 |
Correct |
2 ms |
2284 KB |
Output is correct |
13 |
Correct |
2 ms |
2300 KB |
Output is correct |
14 |
Correct |
2 ms |
2428 KB |
Output is correct |
15 |
Correct |
2 ms |
2284 KB |
Output is correct |
16 |
Correct |
58 ms |
2396 KB |
Output is correct |
17 |
Correct |
57 ms |
2396 KB |
Output is correct |
18 |
Correct |
52 ms |
2284 KB |
Output is correct |
19 |
Correct |
27 ms |
2284 KB |
Output is correct |
20 |
Correct |
3 ms |
2284 KB |
Output is correct |
21 |
Correct |
54 ms |
2284 KB |
Output is correct |
22 |
Correct |
29 ms |
2284 KB |
Output is correct |
23 |
Correct |
13 ms |
2284 KB |
Output is correct |
24 |
Correct |
56 ms |
2284 KB |
Output is correct |
25 |
Correct |
54 ms |
2284 KB |
Output is correct |
26 |
Correct |
3 ms |
2284 KB |
Output is correct |
27 |
Correct |
50 ms |
2284 KB |
Output is correct |
28 |
Correct |
46 ms |
2284 KB |
Output is correct |
29 |
Correct |
3 ms |
2284 KB |
Output is correct |
30 |
Correct |
12 ms |
2284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2284 KB |
Output is correct |
2 |
Correct |
2 ms |
2284 KB |
Output is correct |
3 |
Correct |
2 ms |
2284 KB |
Output is correct |
4 |
Correct |
2 ms |
2304 KB |
Output is correct |
5 |
Correct |
2 ms |
2284 KB |
Output is correct |
6 |
Correct |
2 ms |
2284 KB |
Output is correct |
7 |
Correct |
2 ms |
2304 KB |
Output is correct |
8 |
Correct |
2 ms |
2284 KB |
Output is correct |
9 |
Correct |
1 ms |
2284 KB |
Output is correct |
10 |
Correct |
1 ms |
2284 KB |
Output is correct |
11 |
Correct |
2 ms |
2284 KB |
Output is correct |
12 |
Correct |
2 ms |
2284 KB |
Output is correct |
13 |
Correct |
2 ms |
2300 KB |
Output is correct |
14 |
Correct |
2 ms |
2428 KB |
Output is correct |
15 |
Correct |
2 ms |
2284 KB |
Output is correct |
16 |
Correct |
58 ms |
2396 KB |
Output is correct |
17 |
Correct |
57 ms |
2396 KB |
Output is correct |
18 |
Correct |
52 ms |
2284 KB |
Output is correct |
19 |
Correct |
27 ms |
2284 KB |
Output is correct |
20 |
Correct |
3 ms |
2284 KB |
Output is correct |
21 |
Correct |
54 ms |
2284 KB |
Output is correct |
22 |
Correct |
29 ms |
2284 KB |
Output is correct |
23 |
Correct |
13 ms |
2284 KB |
Output is correct |
24 |
Correct |
56 ms |
2284 KB |
Output is correct |
25 |
Correct |
54 ms |
2284 KB |
Output is correct |
26 |
Correct |
3 ms |
2284 KB |
Output is correct |
27 |
Correct |
50 ms |
2284 KB |
Output is correct |
28 |
Correct |
46 ms |
2284 KB |
Output is correct |
29 |
Correct |
3 ms |
2284 KB |
Output is correct |
30 |
Correct |
12 ms |
2284 KB |
Output is correct |
31 |
Runtime error |
67 ms |
5100 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2284 KB |
Output is correct |
2 |
Correct |
2 ms |
2284 KB |
Output is correct |
3 |
Correct |
2 ms |
2284 KB |
Output is correct |
4 |
Correct |
2 ms |
2304 KB |
Output is correct |
5 |
Correct |
2 ms |
2284 KB |
Output is correct |
6 |
Correct |
2 ms |
2284 KB |
Output is correct |
7 |
Correct |
2 ms |
2304 KB |
Output is correct |
8 |
Correct |
2 ms |
2284 KB |
Output is correct |
9 |
Correct |
1 ms |
2284 KB |
Output is correct |
10 |
Correct |
1 ms |
2284 KB |
Output is correct |
11 |
Correct |
2 ms |
2284 KB |
Output is correct |
12 |
Correct |
2 ms |
2284 KB |
Output is correct |
13 |
Correct |
2 ms |
2300 KB |
Output is correct |
14 |
Correct |
2 ms |
2428 KB |
Output is correct |
15 |
Correct |
2 ms |
2284 KB |
Output is correct |
16 |
Correct |
58 ms |
2396 KB |
Output is correct |
17 |
Correct |
57 ms |
2396 KB |
Output is correct |
18 |
Correct |
52 ms |
2284 KB |
Output is correct |
19 |
Correct |
27 ms |
2284 KB |
Output is correct |
20 |
Correct |
3 ms |
2284 KB |
Output is correct |
21 |
Correct |
54 ms |
2284 KB |
Output is correct |
22 |
Correct |
29 ms |
2284 KB |
Output is correct |
23 |
Correct |
13 ms |
2284 KB |
Output is correct |
24 |
Correct |
56 ms |
2284 KB |
Output is correct |
25 |
Correct |
54 ms |
2284 KB |
Output is correct |
26 |
Correct |
3 ms |
2284 KB |
Output is correct |
27 |
Correct |
50 ms |
2284 KB |
Output is correct |
28 |
Correct |
46 ms |
2284 KB |
Output is correct |
29 |
Correct |
3 ms |
2284 KB |
Output is correct |
30 |
Correct |
12 ms |
2284 KB |
Output is correct |
31 |
Runtime error |
67 ms |
5100 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2284 KB |
Output is correct |
2 |
Correct |
2 ms |
2284 KB |
Output is correct |
3 |
Correct |
2 ms |
2284 KB |
Output is correct |
4 |
Correct |
2 ms |
2304 KB |
Output is correct |
5 |
Correct |
2 ms |
2284 KB |
Output is correct |
6 |
Correct |
2 ms |
2284 KB |
Output is correct |
7 |
Correct |
2 ms |
2304 KB |
Output is correct |
8 |
Correct |
2 ms |
2284 KB |
Output is correct |
9 |
Correct |
1 ms |
2284 KB |
Output is correct |
10 |
Correct |
1 ms |
2284 KB |
Output is correct |
11 |
Correct |
2 ms |
2284 KB |
Output is correct |
12 |
Correct |
2 ms |
2284 KB |
Output is correct |
13 |
Correct |
2 ms |
2300 KB |
Output is correct |
14 |
Correct |
2 ms |
2428 KB |
Output is correct |
15 |
Correct |
2 ms |
2284 KB |
Output is correct |
16 |
Correct |
58 ms |
2396 KB |
Output is correct |
17 |
Correct |
57 ms |
2396 KB |
Output is correct |
18 |
Correct |
52 ms |
2284 KB |
Output is correct |
19 |
Correct |
27 ms |
2284 KB |
Output is correct |
20 |
Correct |
3 ms |
2284 KB |
Output is correct |
21 |
Correct |
54 ms |
2284 KB |
Output is correct |
22 |
Correct |
29 ms |
2284 KB |
Output is correct |
23 |
Correct |
13 ms |
2284 KB |
Output is correct |
24 |
Correct |
56 ms |
2284 KB |
Output is correct |
25 |
Correct |
54 ms |
2284 KB |
Output is correct |
26 |
Correct |
3 ms |
2284 KB |
Output is correct |
27 |
Correct |
50 ms |
2284 KB |
Output is correct |
28 |
Correct |
46 ms |
2284 KB |
Output is correct |
29 |
Correct |
3 ms |
2284 KB |
Output is correct |
30 |
Correct |
12 ms |
2284 KB |
Output is correct |
31 |
Runtime error |
67 ms |
5100 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |