# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1063234 | hahahaha | Cloud Computing (CEOI18_clo) | C++17 | 212 ms | 262144 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;
typedef long long ll;
const int maxn = 2e3+10;
const int maxc = 51;
const ll inf = 2e18+10;
struct Obj
{
int c, f, v;
} a[maxn], b[maxn];
int n, m;
ll dp[maxn][maxn][maxc];
void upd(ll &a, ll b)
{
a = max(a, b);
}
bool comp(Obj a, Obj b)
{
return a.f > b.f;
}
int main(void)
{
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d %d %d", &a[i].c, &a[i].f, &a[i].v);
scanf("%d", &m);
for (int i = 1; i <= m; i++)
scanf("%d %d %d", &b[i].c, &b[i].f, &b[i].v);
sort(a+1, a+n+1, comp);
sort(b+1, b+m+1, comp);
for (int i = n; i >= 0; i--)
{
for (int j = m; j >= 1; j--)
{
for (int c = maxc-1; c >= 0; c--)
{
if (a[i+1].f < b[j].f && c > 0 && c < b[j].c)
{
upd(dp[i][j][c], dp[i][j+1][c]);
continue;
}
upd(dp[i][j][c], dp[i+1][j][c]);
upd(dp[i][j][c], dp[i][j+1][c]);
if (c >= b[j].c)
upd(dp[i][j][c], 1ll*b[j].v + dp[i][j+1][c-b[j].c]);
if (i < n && c < maxc && a[i+1].f >= b[j].f)
upd(dp[i][j][c], dp[i+1][j][c+a[i+1].c] - 1ll*a[i+1].v);
}
}
}
printf("%lld\n", max(0ll, dp[0][1][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... |