#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e5 + 1;
struct str{
int a, b;
} v[nmax];
int main() {
int n, m, k;
cin >> n >> m >> k;
for(int i = 1; i <= n; i ++) {
cin >> v[i].a >> v[i].b;
}
long long dp[n + 1][m + 1][k + 1];
memset(dp, 0, sizeof(dp));
for(int i = 1; i <= n; i ++) {
for(int j = 0; j <= m; j ++) {
for(int p = 0; p <= k; p ++) {
int x = 0;
dp[i][j][p] = dp[i - 1][j][p];
if(j != 0) {
dp[i][j][p] = max(dp[i][j][p], dp[i - 1][j - 1][p] + v[i].a);
}
if(p != 0) {
dp[i][j][p] = max(dp[i][j][p], dp[i - 1][j][p - 1] + v[i].b);
}
}
}
}
cout << dp[n][m][k];
return 0;
}
Compilation message
school.cpp: In function 'int main()':
school.cpp:21:13: warning: unused variable 'x' [-Wunused-variable]
21 | int x = 0;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
6748 KB |
Output is correct |
7 |
Runtime error |
131 ms |
262144 KB |
Execution killed with signal 9 |
8 |
Runtime error |
131 ms |
262144 KB |
Execution killed with signal 9 |
9 |
Runtime error |
133 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Runtime error |
131 ms |
262144 KB |
Execution killed with signal 9 |
11 |
Runtime error |
124 ms |
262144 KB |
Execution killed with signal 9 |
12 |
Runtime error |
128 ms |
262144 KB |
Execution killed with signal 9 |
13 |
Runtime error |
158 ms |
262144 KB |
Execution killed with signal 9 |
14 |
Runtime error |
160 ms |
262144 KB |
Execution killed with signal 9 |
15 |
Runtime error |
37 ms |
2060 KB |
Execution killed with signal 11 |
16 |
Runtime error |
37 ms |
1876 KB |
Execution killed with signal 11 |
17 |
Runtime error |
38 ms |
2084 KB |
Execution killed with signal 11 |
18 |
Runtime error |
45 ms |
2128 KB |
Execution killed with signal 11 |
19 |
Runtime error |
38 ms |
2128 KB |
Execution killed with signal 11 |
20 |
Runtime error |
43 ms |
1880 KB |
Execution killed with signal 11 |