| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1300174 | pete555 | Cloud Computing (CEOI18_clo) | C++20 | 593 ms | 1920 KiB |
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define ll long long
#define pb push_back
#define pf push_front
void fileIO(string filename) {
freopen((filename + ".in").c_str(), "r", stdin);
freopen((filename + ".out").c_str(), "w", stdout);
}
struct Transaction {
int cores;
int rate;
int price;
bool operator<(const Transaction &other) {
return rate > other.rate;
// return price < other.price;
}
};
int main() {
cin.tie(0)->sync_with_stdio(false);
//fileIO("");
int total_cores = 0;
vector<Transaction> Transactions;
int n;
cin >> n;
for(int i = 0; i < n; i++) {
Transaction x;
cin >> x.cores >> x.rate >> x.price;
x.price = -x.price;
Transactions.pb(x);
total_cores += x.cores;
}
int m;
cin >> m;
for(int i = 0; i < m; i++) {
Transaction x;
cin >> x.cores >> x.rate >> x.price;
x.cores = -x.cores;
Transactions.pb(x);
}
sort(Transactions.begin(), Transactions.end());
vector<ll> prev(total_cores + 1, INT64_MIN);
prev[0] = 0;
for(Transaction x : Transactions) {
vector<ll> dp(prev);
for(int i = 0; i <= total_cores; i++) {
int j = i - x.cores;
if(0 <= j && j <= total_cores && prev[j] != INT64_MIN) {
dp[i] = max(dp[i], prev[j] + x.price);
}
}
prev = dp;
}
cout << *max_element(prev.begin(), prev.end()) << '\n';
}
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... | ||||
