# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
997387 | daffuwu | Cloud Computing (CEOI18_clo) | C++14 | 431 ms | 2140 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;
#define fr first
#define sc second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long n, m, dp[2][100069]; //{komp sekarang, order sekarang, core tersisa komp, needed core order}
struct machine
{
long long c, f, v;
bool operator<(const machine other) const
{
if (f == other.f) return c>other.c;
return f<other.f;
}
} a[4069];
int main()
{
long long i, j;
scanf("%lld", &n);
for (i=1; i<=n; i++)
{
scanf("%lld%lld%lld", &a[i].c, &a[i].f, &a[i].v);
a[i].c *= -1;
a[i].v *= -1;
}
scanf("%lld", &m);
for (i=1; i<=m; i++)
{
scanf("%lld%lld%lld", &a[n+i].c, &a[n+i].f, &a[n+i].v);
}
sort(a+1, a+n+m+1);
//dp[i][j] --> max uang kalau total core adalah j
for (j=1; j<=100000; j++) dp[(n+m+1)%2][j] = -1e15;
for (i=n+m; i>=1; i--)
{
for (j=0; j<=100000; j++)
{
dp[i%2][j] = dp[(i+1)%2][j];
if (j+a[i].c<=100000) dp[i%2][j] = max(dp[i%2][j], dp[(i+1)%2][max(0ll, j+a[i].c)]+a[i].v);
}
}
printf("%lld\n", dp[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... |