# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
161231 | rama_pang | Cloud Computing (CEOI18_clo) | C++14 | 1012 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>
using namespace std;
using lint = long long;
const lint INF = 1e15;
struct item { // standard DP Knapsack by reducing the problem to:
int core; // customer negative, shop positive - must be >= 0
int clock; // sort by this descendingly - then we can forget it
int price; // customer positive, shop negative - maximize this
int type; // 1 = shop, 2 = customer
};
int N, M;
item A[5005];
lint DP[2][100005]; // pos and current cores available
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> N; for (int i = 0; i < N; i++) cin >> A[i].core >> A[i].clock >> A[i].price;
cin >> M; for (int i = N; i < N + M; i++) cin >> A[i].core >> A[i].clock >> A[i].price;
for (int i = 0; i < N; i++) A[i].type = 1;
for (int i = N; i < N + M; i++) A[i].type = 2;
sort(A, A + N + M, [&](item l, item r) { return l.clock > r.clock || (l.clock == r.clock && l.type < r.type); });
for (int i = 0; i < N + M; i++) {
if (A[i].type == 1) A[i].price *= -1;
if (A[i].type == 2) A[i].core *= -1;
}
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... |