Submission #990890

#TimeUsernameProblemLanguageResultExecution timeMemory
990890Celebi_276Schools (IZhO13_school)C++17
30 / 100
2 ms604 KiB
#include <bits/stdc++.h> using namespace std; int k, n, m, a[1024], b[1024]; vector <vector <int>> dp[2]; bool p, q; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> k >> n >> m; for (int i = 1; i <= k; i++) cin >> a[i] >> b[i]; dp[0].assign(n + 1, vector<int>(m + 1, 0)); dp[1].assign(n + 1, vector<int>(m + 1, 0)); p = 1; q = 0; for (int i = 1; i <= k; i++) { swap(p, q); for (int x = 0; x <= n; x++) for (int y = 0; y <= m; y++) { dp[q][x][y] = dp[p][x][y]; if (x) dp[q][x][y] = max(dp[q][x][y], dp[p][x - 1][y] + a[i]); if (y) dp[q][x][y] = max(dp[q][x][y], dp[p][x][y - 1] + b[i]); } } cout << dp[q][n][m]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...