# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
783870 | nonono | Cloud Computing (CEOI18_clo) | C++14 | 274 ms | 1328 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 <bits/stdc++.h>
#define int long long
using namespace std;
struct cpt {
int c, f, v;
bool operator < (const cpt &x) const {
return f > x.f;
}
};
const int inf = 1e18;
const int mxN = 2005;
const int mxC = 50;
int n, m;
int dp[mxN * mxC];
signed main() {
#define name ""
if(fopen(name".in", "r")) {
freopen(name".in", "r", stdin);
freopen(name".out", "w", stdout);
}
cin.tie(0)->sync_with_stdio(0);
cin >> n;
vector<cpt> a, b;
for(int i = 1; i <= n; i ++) {
int c, f, v;
cin >> c >> f >> v;
a.push_back({c, f, v});
}
sort(a.begin(), a.end());
cin >> m;
for(int i = 1; i <= m; i ++) {
int c, f, v;
cin >> c >> f >> v;
b.push_back({c, f, v});
}
sort(b.begin(), b.end());
for(int i = 0; i <= n * mxC; i ++) dp[i] = inf;
int sumC = 0;
dp[0] = 0;
for(int i = 0, j = 0; i < m; i ++) {
for(; j < n && a[j].f >= b[i].f; j ++) {
sumC += a[j].c;
for(int k = sumC; k >= a[j].c; k --) {
dp[k] = min(dp[k], dp[k - a[j].c] + a[j].v);
}
}
for(int k = b[i].c; k <= sumC; k ++) {
dp[k - b[i].c] = min(dp[k - b[i].c], dp[k] - b[i].v);
}
}
int result = 0;
for(int i = 0; i <= sumC; i ++) result = max(result, - dp[i]);
cout << result << "\n";
return 0;
}
Compilation message (stderr)
# | 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... |