# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217589 | DystoriaX | Cloud Computing (CEOI18_clo) | C++14 | 50 ms | 560 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>
using namespace std;
struct node{
int c, f, v;
};
int n, m;
const int MAX = 10010;
vector<node> comp, dem;
priority_queue<int, vector<int>, greater<int> > pq;
long long ans = 0, dp[MAX], dps[MAX];
bool cp(node a, node b){
return a.f > b.f;
}
int main(){
scanf("%d", &n);
comp.resize(n + 1);
for(int i = 1; i <= n; i++) scanf("%d%d%d", &comp[i].c, &comp[i].f, &comp[i].v);
scanf("%d", &m);
dem.resize(m + 1);
for(int i = 1; i <= m; i++) scanf("%d%d%d", &dem[i].c, &dem[i].f, &dem[i].v);
sort(comp.begin() + 1, comp.end(), cp);
sort(dem.begin() + 1, dem.end(), cp);
//dp = minCost, maxProfit
for(int i = 0; i < MAX; i++) dp[i] = 1e18;
dp[0] = 0;
for(int i = 1; i <= n; i++)
for(int k = MAX - 1; k >= comp[i].c; k--)
dp[k] = min(dp[k], dp[k - comp[i].c] + comp[i].v);
for(int i = 1; i <= m; i++)
for(int k = MAX - 1; k >= dem[i].c; k--)
dps[k] = max(dps[k], dps[k - dem[i].c] + dem[i].v);
for(int i = MAX - 2; i; i--)
dp[i] = min(dp[i], dp[i + 1]);
for(int i = 1; i < MAX; i++)
dps[i] = max(dps[i], dps[i - 1]);
for(int i = 0; i < MAX; i++) ans = max(ans, dps[i] - dp[i]);
printf("%lld\n", ans);
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... |