# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
488128 | TruaShamu | Cloud Computing (CEOI18_clo) | C++17 | 681 ms | 1872 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 ll = long long;
using vi = vector<int>;
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
using pi = pair<int, int>;
#define f first
#define s second
#define mp make_pair
void setIO(string name = "") {
cin.tie(0)->sync_with_stdio(0); // see /general/fast-io
if (sz(name)) {
freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
freopen((name + ".out").c_str(), "w", stdout);
}
}
struct event {
int cores;
int rate;
int price;
bool operator < (const event& b) const {
return rate != b.rate ? rate > b.rate : price < b.price;
}
};
int main() {
setIO();
vector<event> events;
int N; cin >> N;
// Computer
int maxComp = 0;
for (int i = 0; i < N; i++) {
event oEvent;
cin >> oEvent.cores >> oEvent.rate >> oEvent.price;
oEvent.price *= -1;
events.pb(oEvent);
maxComp += oEvent.cores;
}
// Order
int M; cin >> M;
for (int i = 0; i < M; i++) {
event oEvent;
cin >> oEvent.cores >> oEvent.rate >> oEvent.price;
oEvent.cores *= -1;
events.pb(oEvent);
}
// Print
std::sort(events.begin(), events.end());
vector<ll> dp(maxComp + 1, INT_MIN);
dp[0] = 0;
for (const event& oEvent : events) {
vector<ll> newMax(dp);
for (int c = 0; c <= maxComp; c++) {
int prevComp = c - oEvent.cores;
if (prevComp >= 0 && prevComp <= maxComp && dp[prevComp] != INT_MIN) {
newMax[c] = max(newMax[c], dp[prevComp] + oEvent.price);
}
}
dp = newMax;
}
cout << *max_element(dp.begin(), dp.end());
}
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... |