Submission #761667

#TimeUsernameProblemLanguageResultExecution timeMemory
761667vgoofficialCloud Computing (CEOI18_clo)C++14
100 / 100
783 ms2104 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; struct Order { ll numCores, clockRate, money; }; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int total=0; int n,m; cin >> n; vector<Order> shops; for(int i = 0; i < n; i++) { Order temp; cin >> temp.numCores >> temp.clockRate >> temp.money; temp.money=-temp.money; shops.push_back(temp); total+=temp.numCores; } cin >> m; for(int i = 0; i < m; i++) { Order temp; cin >> temp.numCores >> temp.clockRate >> temp.money; temp.numCores=-temp.numCores; shops.push_back(temp); } sort(shops.begin(), shops.end(), [](const Order &a, const Order &b) -> bool{ return a.clockRate != b.clockRate ? a.clockRate > b.clockRate : a.money < b.money; }); vector<ll> maxProfit(total+1, -1e14); maxProfit[0]=0; for(int i = 0; i < shops.size(); i++) { vector<ll> tempMaxProfit(maxProfit); for(int j = 0; j <= total; j++) { int prev = j - shops[i].numCores; if(prev>=0&&prev<=total&&maxProfit[prev]!=-1e14) { tempMaxProfit[j]=max(tempMaxProfit[j], maxProfit[prev]+shops[i].money); } } maxProfit=tempMaxProfit; } cout << *max_element(maxProfit.begin(), maxProfit.end()) << endl; } /* 3 4 2200 700 2 1800 10 4 2000 750 3 1 1500 300 6 1900 1500 3 2400 4550 */

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Order>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i = 0; i < shops.size(); i++) {
      |                    ~~^~~~~~~~~~~~~~
#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...