# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
163001 | Akashi | Cloud Computing (CEOI18_clo) | C++14 | 816 ms | 2116 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 usu{
int c, f, v, t;
bool operator < (const usu &aux)const{
if(f != aux.f) return f < aux.f;
return t > aux.t;
}
};
usu a[4005];
int n, nr;
long long d[2][100005];
int main()
{
// freopen("1.in", "r", stdin);
scanf("%d", &n);
for(int i = 1; i <= n ; ++i){
++nr;
scanf("%d%d%d", &a[nr].c, &a[nr].f, &a[nr].v);
a[nr].t = 0;
}
scanf("%d", &n);
for(int i = 1; i <= n ; ++i){
++nr;
scanf("%d%d%d", &a[nr].c, &a[nr].f, &a[nr].v);
a[nr].t = 1;
}
sort(a + 1, a + nr + 1);
int l = 0;
memset(d[1], -0x3f, sizeof(d[1]));
d[1][0] = 0;
for(int i = 1; i <= nr ; ++i, l = 1 - l){
for(int j = 0; j <= 100000 ; ++j) d[l][j] = d[1 - l][j];
if(a[i].t == 0){
for(int j = 1; j < a[i].c ; ++j)
d[l][0] = max(d[l][0], d[1 - l][j] - a[i].v);
for(int j = 0; j + a[i].c <= 100000 ; ++j)
d[l][j] = max(d[l][j], d[1 - l][j + a[i].c] - a[i].v);
}
else{
for(int j = a[i].c; j <= 100000 ; ++j)
d[l][j] = max(d[l][j], d[1 - l][j - a[i].c] + a[i].v);
}
}
l = 1 - l;
printf("%lld", d[l][0]);
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... |