# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
756379 | Olympia | 학교 설립 (IZhO13_school) | C++17 | 157 ms | 262144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |