제출 #575451

#제출 시각아이디문제언어결과실행 시간메모리
575451codebuster_10Cloud Computing (CEOI18_clo)C++17
100 / 100
1397 ms5380 KiB
#include <bits/stdc++.h> #define int int64_t //be careful about this using namespace std; struct item{ int type,cores,clock_rate,value; }; signed main(){ int n; cin >> n; vector<item> items; while(n--){ int c,f,v; cin >> c >> f >> v; items.push_back({0,c,f,v}); } int m; cin >> m; while(m--){ int c,f,v; cin >> c >> f >> v; items.push_back({1,c,f,v}); } sort(items.begin(), items.end(),[&](auto l,auto r){ return l.clock_rate == r.clock_rate ? l.type > r.type : l.clock_rate < r.clock_rate; }); auto upd = [&](vector<int>& dp,int i,int profit){ while(int(dp.size()) <= i) dp.push_back(-1e16); if(dp[i] < profit) dp[i] = profit; }; vector<int> dp; upd(dp,0,0); for(auto [type,cores,clock_rate,value] : items){ vector<int> ndp = dp; for(int need = 0; need < int(dp.size()); ++need){ int new_need = max(int(0),need + (type == 0 ? -1 : +1) * cores); int new_profit = dp[need] + (type == 0 ? -1 : +1) * value; upd(ndp,new_need,new_profit); } dp = ndp; } cout << dp[0]; return 0; }
#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...