# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
205700 | dolphingarlic | Cloud Computing (CEOI18_clo) | C++14 | 830 ms | 2168 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>
#pragma GCC optimize("unroll-loops")
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
const ll INF = LLONG_MIN / 2;
struct Object {
int c;
ll f, v;
bool operator<(Object B) {
if (f == B.f) {
if (v == B.v) return c > B.c;
return v > B.v;
}
return f > B.f;
}
} obj[4001];
ll dp[2][100001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n;
FOR(i, 0, n) {
cin >> obj[i].c >> obj[i].f >> obj[i].v;
obj[i].v *= -1;
}
cin >> m;
FOR(i, n, n + m) {
cin >> obj[i].c >> obj[i].f >> obj[i].v;
obj[i].c *= -1;
}
sort(obj, obj + n + m);
FOR(i, 0, 2) FOR(j, 0, 100001) dp[i][j] = INF;
dp[1][0] = 0;
FOR(i, 0, n + m) {
FOR(j, 0, 99951) {
if (j >= obj[i].c)
dp[i & 1][j] = max(dp[1 - i & 1][j], dp[1 - i & 1][j - obj[i].c] + obj[i].v);
else
dp[i & 1][j] = dp[1 - i & 1][j];
}
FOR(j, 0, 100001) dp[1 - i & 1][j] = INF;
}
cout << *max_element(dp[1 - (n + m) & 1], dp[1 - (n + m) & 1] + 100001);
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... |