#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
const long long inf = 1000000000000007;
const int maxn = 3000;
int n;
int a[maxn];
long long dp[maxn][maxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i = 0; i < n; i++){
cin >> a[i];
dp[0][i] = a[i] + (i ? dp[0][i - 1] : 0);
}
int ret = 1;
for(int i = 1; i < n; i++)
for(int j = 0; j < n; j++){
dp[i][j] = inf;
for(long long k = j - 1, s = a[j]; k >= 0; k--){
if(dp[i - 1][k] <= s){
dp[i][j] = s;
break;
}
s += a[k];
}
if(dp[i][j] != inf) ret = i + 1;
}
cout << ret << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
51 ms |
4344 KB |
Output is correct |
17 |
Correct |
49 ms |
4348 KB |
Output is correct |
18 |
Correct |
42 ms |
4344 KB |
Output is correct |
19 |
Correct |
31 ms |
4344 KB |
Output is correct |
20 |
Correct |
21 ms |
4344 KB |
Output is correct |
21 |
Correct |
45 ms |
4288 KB |
Output is correct |
22 |
Correct |
26 ms |
3192 KB |
Output is correct |
23 |
Correct |
14 ms |
2296 KB |
Output is correct |
24 |
Correct |
45 ms |
4344 KB |
Output is correct |
25 |
Correct |
45 ms |
4344 KB |
Output is correct |
26 |
Correct |
21 ms |
4344 KB |
Output is correct |
27 |
Correct |
44 ms |
4344 KB |
Output is correct |
28 |
Correct |
41 ms |
4344 KB |
Output is correct |
29 |
Correct |
21 ms |
4348 KB |
Output is correct |
30 |
Correct |
25 ms |
4344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
51 ms |
4344 KB |
Output is correct |
17 |
Correct |
49 ms |
4348 KB |
Output is correct |
18 |
Correct |
42 ms |
4344 KB |
Output is correct |
19 |
Correct |
31 ms |
4344 KB |
Output is correct |
20 |
Correct |
21 ms |
4344 KB |
Output is correct |
21 |
Correct |
45 ms |
4288 KB |
Output is correct |
22 |
Correct |
26 ms |
3192 KB |
Output is correct |
23 |
Correct |
14 ms |
2296 KB |
Output is correct |
24 |
Correct |
45 ms |
4344 KB |
Output is correct |
25 |
Correct |
45 ms |
4344 KB |
Output is correct |
26 |
Correct |
21 ms |
4344 KB |
Output is correct |
27 |
Correct |
44 ms |
4344 KB |
Output is correct |
28 |
Correct |
41 ms |
4344 KB |
Output is correct |
29 |
Correct |
21 ms |
4348 KB |
Output is correct |
30 |
Correct |
25 ms |
4344 KB |
Output is correct |
31 |
Execution timed out |
1576 ms |
13816 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
51 ms |
4344 KB |
Output is correct |
17 |
Correct |
49 ms |
4348 KB |
Output is correct |
18 |
Correct |
42 ms |
4344 KB |
Output is correct |
19 |
Correct |
31 ms |
4344 KB |
Output is correct |
20 |
Correct |
21 ms |
4344 KB |
Output is correct |
21 |
Correct |
45 ms |
4288 KB |
Output is correct |
22 |
Correct |
26 ms |
3192 KB |
Output is correct |
23 |
Correct |
14 ms |
2296 KB |
Output is correct |
24 |
Correct |
45 ms |
4344 KB |
Output is correct |
25 |
Correct |
45 ms |
4344 KB |
Output is correct |
26 |
Correct |
21 ms |
4344 KB |
Output is correct |
27 |
Correct |
44 ms |
4344 KB |
Output is correct |
28 |
Correct |
41 ms |
4344 KB |
Output is correct |
29 |
Correct |
21 ms |
4348 KB |
Output is correct |
30 |
Correct |
25 ms |
4344 KB |
Output is correct |
31 |
Execution timed out |
1576 ms |
13816 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
51 ms |
4344 KB |
Output is correct |
17 |
Correct |
49 ms |
4348 KB |
Output is correct |
18 |
Correct |
42 ms |
4344 KB |
Output is correct |
19 |
Correct |
31 ms |
4344 KB |
Output is correct |
20 |
Correct |
21 ms |
4344 KB |
Output is correct |
21 |
Correct |
45 ms |
4288 KB |
Output is correct |
22 |
Correct |
26 ms |
3192 KB |
Output is correct |
23 |
Correct |
14 ms |
2296 KB |
Output is correct |
24 |
Correct |
45 ms |
4344 KB |
Output is correct |
25 |
Correct |
45 ms |
4344 KB |
Output is correct |
26 |
Correct |
21 ms |
4344 KB |
Output is correct |
27 |
Correct |
44 ms |
4344 KB |
Output is correct |
28 |
Correct |
41 ms |
4344 KB |
Output is correct |
29 |
Correct |
21 ms |
4348 KB |
Output is correct |
30 |
Correct |
25 ms |
4344 KB |
Output is correct |
31 |
Execution timed out |
1576 ms |
13816 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |