# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146105 | raghav0307 | Cloud Computing (CEOI18_clo) | C++14 | 3024 ms | 5012 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.
// Kamil Debowski
// OBL, AC solution
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
vector<pair<int, pair<int,int>>> events;
for(int rep = 0; rep < 2; ++rep) {
int n;
scanf("%d", &n);
while(n--) {
int cnt, freq, cost;
scanf("%d%d%d", &cnt, &freq, &cost);
if(rep == 0) {
cost *= -1; // cost of CPU
}
else {
cnt *= -1;
}
// otherwise gain from a task
events.push_back({freq, {cnt, cost}});
}
}
sort(events.rbegin(), events.rend());
vector<ll> dp{0};
for(int i = 0; i < (int) events.size(); ++i) {
vector<ll> dp2 = dp;
for(int cnt = 0; cnt < (int) dp.size(); ++cnt) {
int cnt2 = cnt + events[i].second.first;
ll maybe_cost = dp[cnt] + events[i].second.second;
if(cnt2 >= 0) {
while((int) dp2.size() <= cnt2) dp2.push_back(LONG_LONG_MIN / 2);
dp2[cnt2] = max(dp2[cnt2], maybe_cost);
}
}
dp = dp2;
}
ll answer = 0;
for(ll x : dp) answer = max(answer, x);
printf("%lld\n", answer);
}
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... |