Submission #1132481

#TimeUsernameProblemLanguageResultExecution timeMemory
1132481ocasuCloud Computing (CEOI18_clo)C++20
100 / 100
416 ms2168 KiB
#include <bits/stdc++.h> using namespace std; #define int long long struct Transaction { int cores; int rate; int price; }; const int MAXCORES=100000; const int inf=1e12; signed main(){ int n; cin>>n; vector<Transaction> transactions; for (int i=0; i<n; i++){ Transaction trans; cin>>trans.cores>>trans.rate>>trans.price; trans.price *= -1; transactions.push_back(trans); } int m; cin>>m; for (int i=0; i<m; i++){ Transaction trans; cin>>trans.cores>>trans.rate>>trans.price; trans.cores *= -1; transactions.push_back(trans); } std::sort(transactions.begin(), transactions.end(), [](const Transaction &a, const Transaction &b) -> bool { return a.rate != b.rate ? a.rate > b.rate : a.price < b.price; }); vector<int> dp(MAXCORES+1,-inf); dp[0]=0; for (auto trans: transactions){ vector<int> ndp = dp; for (int i=0; i<=MAXCORES; i++){ if (dp[i]!=-inf and 0<=i+trans.cores and i+trans.cores<=MAXCORES) ndp[i+trans.cores] = max(ndp[i+trans.cores], dp[i] + trans.price); } swap(dp, ndp); } cout<<*max_element(dp.begin(),dp.end())<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...