#include <bits/stdc++.h>
using namespace std;
#define int long long
int dp[2005][2005];
signed main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int n, k; cin >> n >> k;
int a[n + 1]; for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++) a[i] += a[i - 1];
for(int i = 1; i <= n; i++){
for(int j = 1; j <= k; j++){
dp[i][j] = max(dp[i][j], dp[i - 1][j]);
for(int l = 0; l < i; l++) dp[i][j] = max(dp[i][j], dp[l][j - 1] + a[i] - a[l]);
}
}
cout << dp[n][k];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1053 ms |
10120 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
45 ms |
22608 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
52 ms |
24660 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
616 KB |
Output is correct |
4 |
Correct |
1 ms |
616 KB |
Output is correct |
5 |
Correct |
0 ms |
616 KB |
Output is correct |
6 |
Correct |
1 ms |
616 KB |
Output is correct |
7 |
Correct |
1 ms |
616 KB |
Output is correct |
8 |
Correct |
0 ms |
616 KB |
Output is correct |
9 |
Correct |
0 ms |
616 KB |
Output is correct |
10 |
Correct |
0 ms |
616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
616 KB |
Output is correct |
4 |
Correct |
1 ms |
616 KB |
Output is correct |
5 |
Correct |
0 ms |
616 KB |
Output is correct |
6 |
Correct |
1 ms |
616 KB |
Output is correct |
7 |
Correct |
1 ms |
616 KB |
Output is correct |
8 |
Correct |
0 ms |
616 KB |
Output is correct |
9 |
Correct |
0 ms |
616 KB |
Output is correct |
10 |
Correct |
0 ms |
616 KB |
Output is correct |
11 |
Correct |
3 ms |
1640 KB |
Output is correct |
12 |
Correct |
4 ms |
1712 KB |
Output is correct |
13 |
Correct |
2 ms |
1384 KB |
Output is correct |
14 |
Correct |
3 ms |
1640 KB |
Output is correct |
15 |
Correct |
2 ms |
1640 KB |
Output is correct |
16 |
Correct |
2 ms |
1384 KB |
Output is correct |
17 |
Correct |
3 ms |
1640 KB |
Output is correct |
18 |
Correct |
1 ms |
1384 KB |
Output is correct |
19 |
Correct |
1 ms |
1384 KB |
Output is correct |
20 |
Correct |
1 ms |
1640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
616 KB |
Output is correct |
4 |
Correct |
1 ms |
616 KB |
Output is correct |
5 |
Correct |
0 ms |
616 KB |
Output is correct |
6 |
Correct |
1 ms |
616 KB |
Output is correct |
7 |
Correct |
1 ms |
616 KB |
Output is correct |
8 |
Correct |
0 ms |
616 KB |
Output is correct |
9 |
Correct |
0 ms |
616 KB |
Output is correct |
10 |
Correct |
0 ms |
616 KB |
Output is correct |
11 |
Correct |
3 ms |
1640 KB |
Output is correct |
12 |
Correct |
4 ms |
1712 KB |
Output is correct |
13 |
Correct |
2 ms |
1384 KB |
Output is correct |
14 |
Correct |
3 ms |
1640 KB |
Output is correct |
15 |
Correct |
2 ms |
1640 KB |
Output is correct |
16 |
Correct |
2 ms |
1384 KB |
Output is correct |
17 |
Correct |
3 ms |
1640 KB |
Output is correct |
18 |
Correct |
1 ms |
1384 KB |
Output is correct |
19 |
Correct |
1 ms |
1384 KB |
Output is correct |
20 |
Correct |
1 ms |
1640 KB |
Output is correct |
21 |
Correct |
737 ms |
11092 KB |
Output is correct |
22 |
Execution timed out |
1098 ms |
15992 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1053 ms |
10120 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |