| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1340864 | msun | Cloud Computing (CEOI18_clo) | C++20 | 486 ms | 2056 KiB |
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#define int long long
using namespace std;
#define MAXN 2020
#define MAXC 100100
// #define MAXC 100
array<int, 3> inp[2 * MAXN];
int dp[MAXC], dp0[MAXC];
signed
main ()
{
// freopen ("test.in", "r", stdin);
int N;
scanf ("%lld", &N);
int C = 0;
for (int i = 1; i <= N; ++i) {
int c, f, v;
scanf ("%lld%lld%lld", &c, &f, &v);
inp[i][2] = c;
inp[i][0] = -f;
inp[i][1] = -v;
C += c;
}
int M;
scanf ("%lld", &M);
int len = N + M;
for (int i = N + 1; i <= len; ++i) {
int c, f, v;
scanf ("%lld%lld%lld", &c, &f, &v);
inp[i][2] = -c;
inp[i][0] = -f;
inp[i][1] = v;
}
sort (inp + 1, inp + len + 1);
memset (dp, -0x3f, sizeof dp);
memset (dp0, -0x3f, sizeof dp);
dp[0] = dp0[0] = 0;
for (int i = 1; i <= len; ++i) {
auto [_, v, c] = inp[i];
for (int j = 0; j <= C; ++j)
if (j >= c && j - c <= C)
dp[j] = max (dp0[j], dp0[j - c] + v);
memcpy (dp0, dp, sizeof dp0);
}
printf ("%lld\n", *max_element (dp, dp + C + 1));
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... | ||||
