# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
916968 | ThommyDB | Cloud Computing (CEOI18_clo) | C++17 | 367 ms | 3924 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;
#define int long long
struct ComputersOrOrders{
int cores;
int clockSpeed;
int price;
};
int n, m;
vector<ComputersOrOrders> computers;
vector<ComputersOrOrders> orders;
int memo[(int)2e5+100];
int mem[(int)2e5+100];
int DP(){
memset(memo, 1, sizeof(memo));
memo[0] = 0;
for(int i = 0; i < n; i++){
for(int j = 50*n; j >= computers[i].cores; j--){
memo[j] = min(memo[j], memo[j-computers[i].cores]+computers[i].price);
}
}
for(int i = n-1; i >= 0; i--) memo[i]=min(memo[i], memo[i+1]);
mem[0]=0;
for(int i = 0; i < m; i++){
for(int j = 50*n; j >= orders[i].cores; j--){
mem[j] = max(mem[j], mem[j-orders[i].cores] + orders[i].price);
}
}
int ans = 0;
for(int i = 0; i <= 50*n; i++){
ans = max(ans, mem[i]-memo[i]);
}
return ans;
}
signed main(){
cin >> n;
computers.resize(n);
int c, f, v;
for(int i = 0; i <n; i++){
cin >> computers[i].cores >> computers[i].clockSpeed >> computers[i].price;
}
cin >> m;
orders.resize(m);
for(int i = 0; i < m; i++){
cin >> orders[i].cores >> orders[i].clockSpeed >> orders[i].price;
}
cout << DP() << "\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... |