이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
typedef long double ld;
int N, M, f, c, v, dp[2][200005];
vector<tuple<int, int, int> > F, S, V;
main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N;
for (int i = 1, c, f, v; i <= N; i++) {
cin >> c >> f >> v;
F.eb(-f, c, -v);
}
cin >> M;
for (int i = 1; i <= M; i++) {
cin >> c >> f >> v;
S.eb(-f, -c, v);
}
sort(F.begin(), F.end());
sort(S.begin(), S.end());
merge(F.begin(), F.end(), S.begin(), S.end(), back_inserter(V));
for (int i = N + M; i >= 1; i--)
for (int j = 0; j <= 200000; j++)
if (j + get<1>(V[i - 1]) >= 0) dp[i & 1][j] = max(dp[1 - (i & 1)][j + get<1>(V[i - 1])] + get<2>(V[i - 1]), dp[1 - (i & 1)][j]);
else dp[i & 1][j] = dp[1 - (i & 1)][j];
cout << dp[1][0] << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp:14:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |