이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
const int mxN=2000;
int n, m;
ll dp[50*mxN+1];
vector<ar<int, 4>> v;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i=0; i<n; ++i) {
int c, f, p;
cin >> c >> f >> p;
v.push_back({-f, 1, c, p});
}
cin >> m;
for (int i=0; i<m; ++i) {
int c, f, p;
cin >> c >> f >> p;
v.push_back({-f, 2, c, p});
}
sort(v.begin(), v.end());
memset(dp, 0xbf, sizeof(dp));
dp[0]=0;
int tot=0;
for (auto [aalala, t, c, p] : v) {
if (t==1) {
tot+=c;
for (int i=tot; i>=c; --i)
dp[i]=max(dp[i], dp[i-c]-p);
} else {
for (int i=0; i<=tot-c; ++i)
dp[i]=max(dp[i], dp[i+c]+p);
}
/*for (int i=0; i<=tot; ++i)
cout << (dp[i]<1e18?-10000000:dp[i]) << " " << " ";
cout << endl;*/
}
cout << *max_element(dp, dp+50*n+1);
return 0;
}
# | 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... |