# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
932936 | stefanneagu | Schools (IZhO13_school) | C++17 | 160 ms | 262144 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |