# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
763643 | vjudge1 | Cloud Computing (CEOI18_clo) | C++17 | 238 ms | 2152 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 <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
const int maxn = (int) 2e5 + 5;
struct node { int c, f, v; bool data; } a[4005];
int C, n, m, num, ans, dp[maxn];
bool cmp(node x, node y) {
if(x.f != y.f)
return x.f > y.f;
if(x.data != y.data)
return x.data < y.data;
if(!x.data)
return x.v < y.v;
return x.v > y.v;
}
signed main() {
memset(dp, -0x3f, sizeof(dp));
dp[0] = 0;
scanf("%lld", &n);
for(int i = 1; i <= n; i++) {
scanf("%lld %lld %lld", &a[i].c, &a[i].f, &a[i].v);
a[i].data = 0;
}
scanf("%lld", &m);
for(int i = n + 1; i <= n + m; i++) {
scanf("%lld %lld %lld", &a[i].c, &a[i].f, &a[i].v);
a[i].data = 1;
}
num = m + n;
std :: stable_sort(a + 1, a + num + 1, cmp);
/*
for(int i = 1; i <= num; i++)
printf("%d %d %d %d\n", a[i].c, a[i].f, a[i].v, a[i].data);
*/
for(int i = 1; i <= num; i++) {
if(!a[i].data) { // 计算机
C += a[i].c;
for(int j = C; j >= a[i].c; j--)
dp[j] = std :: max(dp[j], dp[j - a[i].c] - a[i].v);
} else { // 客户
for(int j = 0; j <= C - a[i].c; j++)
dp[j] = std :: max(dp[j], dp[j + a[i].c] + a[i].v);
}
}
for(int i = 0; i <= C; i++)
ans = std :: max(ans, dp[i]);
printf("%lld", 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... |