# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217606 | DystoriaX | Cloud Computing (CEOI18_clo) | C++14 | 413 ms | 1284 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 = 100001;
vector<node> comp, dem;
priority_queue<int, vector<int>, greater<int> > pq;
long long ans = 0, dp[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 = maxProfit
for(int i = 0; i < MAX; i++) dp[i] = -1e18;
dp[0] = 0;
int idx = 1;
for(int i = 1; i <= m; i++){
while(idx <= n && comp[idx].f >= dem[i].f){
for(int k = MAX - 1; k >= comp[idx].c; k--){
dp[k] = max(dp[k], dp[k - comp[idx].c] - comp[idx].v);
}
idx++;
}
for(int k = 0; k + dem[i].c < MAX; k++){
dp[k] = max(dp[k], dp[k + dem[i].c] + dem[i].v);
}
}
for(int i = 0; i < MAX; i++) ans = max(ans, 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... |