# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132614 | alexpetrescu | Cloud Computing (CEOI18_clo) | C++14 | 303 ms | 1400 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 <algorithm>
#include <vector>
//FILE *fin = fopen("a.in", "r"), *fout = fopen("a.out", "w");
#define fin stdin
#define fout stdout
struct myc {
int c, f, v, t;
inline bool operator < (const myc &u) const {
if (f != u.f) return f < u.f;
else return t > u.t;
}
};
long long d[100009];
inline void _(long long &a, long long b) {
a = std::max(a, b);
}
int main() {
int calc;
fscanf(fin, "%d", &calc);
std::vector < myc > v;
for (; calc; calc--) {
int c, f, V;
fscanf(fin, "%d%d%d", &c, &f, &V);
v.push_back({c, f, V, 0});
}
int coma;
fscanf(fin, "%d", &coma);
for (; coma; coma--) {
int c, f, V;
fscanf(fin, "%d%d%d", &c, &f, &V);
v.push_back({c, f, V, 1});
}
std::sort(v.begin(), v.end());
int sumC = 0;
for (auto &x : v) {
if (x.t) {
for (int i = sumC; i >= 0; i--)
_(d[i + x.c], d[i] + x.v);
sumC += x.c;
} else {
for (int i = 1; i < x.c; i++)
_(d[0], d[i] - x.v);
for (int i = x.c; i <= sumC; i++)
_(d[i - x.c], d[i] - x.v);
}
}
fprintf(fout, "%lld\n", d[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... |