Submission #756379

#TimeUsernameProblemLanguageResultExecution timeMemory
756379OlympiaSchools (IZhO13_school)C++17
30 / 100
157 ms262144 KiB
#include <vector> #include <iostream> #include <cassert> #include <random> #include <cmath> #include <map> #include <algorithm> #include <bitset> #include <queue> #include <set> #include <stack> using namespace std; int main () { ios_base::sync_with_stdio(false); cin.tie(NULL); int N, M, S; cin >> N >> M >> S; vector<pair<int64_t,int64_t>> vec(N); for (int i = 0; i < N; i++) { cin >> vec[i].first >> vec[i].second; } int64_t dp[N + 1][M + 1][S + 1]; for (int n = 0; n <= N; n++) { for (int m = 0; m <= M; m++) { for (int s = 0; s <= S; s++) { if (n == 0 and m == 0 and s == 0) { dp[n][m][s] = 0; } else if (n == 0) { dp[n][m][s] = -(int64_t)1e17; } else { dp[n][m][s] = dp[n - 1][m][s]; } if (n != 0 and m != 0) { dp[n][m][s] = max(dp[n][m][s], dp[n - 1][m - 1][s] + vec[n - 1].first); } if (n != 0 and s != 0) { dp[n][m][s] = max(dp[n][m][s], dp[n - 1][m][s - 1] + vec[n - 1].second); } //cout << n << " " << m << " " << s << " " << dp[n][m][s] << endl; } } } cout << dp[N][M][S] << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...