Submission #530571

#TimeUsernameProblemLanguageResultExecution timeMemory
530571FelipeHHotel (CEOI11_hot)C++14
10 / 100
2675 ms8396 KiB
#include<bits/stdc++.h> using namespace std; using pii = pair<int,int>; vector<int> roomSize, roomCost; vector<pii> offer; int main(){ int n, m, o; cin >> n >> m >> o; for(int i = 0;i<n;i++){ int a, b; cin >> a >> b; roomCost.push_back(a); roomSize.push_back(b); } sort(roomCost.begin(),roomCost.end() - 1); sort(roomSize.begin(),roomSize.end() - 1); for(int i = 0;i<m;i++){ int a, b; cin >> a >> b; offer.push_back(make_pair(a,b)); } sort(offer.begin(),offer.end() - 1); int resp = 0, cnt = 0; for(int i = offer.size() - 1; i >= 0 && cnt <= o; i--){ if(roomCost.empty()) break; // printf("processing offer (%d,%d)\n",offer[i].first, offer[i].second); auto it = lower_bound(roomSize.begin(), roomSize.end(), offer[i].second); if(it == roomSize.end()) continue; int roomId = it - roomSize.begin(); // printf("-chose room %d (%d,%d)\n",roomId, roomCost[roomId], roomSize[roomId]); if(offer[i].first - roomCost[roomId] > 0){ resp += offer[i].first - roomCost[roomId]; roomCost.erase(roomCost.begin() + roomId); roomSize.erase(roomSize.begin() + roomId); cnt++; } } cout << resp << "\n"; 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...