# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
756379 | Olympia | Schools (IZhO13_school) | C++17 | 157 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 <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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |