# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
591001 | 2022-07-06T17:08:12 Z | web | Hotel (CEOI11_hot) | C++17 | 937 ms | 36088 KB |
#include <iostream> #include <vector> #include <algorithm> using namespace std; int binarySearchRoom(long people, long value, vector<long>& roomOffers, vector<pair<long,long> >& roomCaps) { int min = 0, max = roomOffers.size(); while(max > min) { int mid = (max+min)/2; if(roomCaps[mid].first < people) { min = mid+1; continue; } else { if(roomOffers[mid] < value) { if(max == mid+1) return mid; max = mid+1; continue; } else { min = mid+1; continue; } } } if(min == roomOffers.size()) return -1; else { return min; } } int main() { long n, m , o; cin>>n>>m>>o; vector<pair<long, long>> rooms(n); vector<pair<long,long> > offers(m); for(int i = 0; i<n; ++i) { long a,b; cin>>a>>b; rooms[i].second = -a; rooms[i].first = b; } for(int i = 0; i<m; ++i) cin>>offers[i].second>>offers[i].first; sort(rooms.begin(), rooms.end()); sort(offers.rbegin(), offers.rend()); vector<long> bestOfferRoom(n, 0); for(int i = 0; i<offers.size(); ++i) { int indexInsert = binarySearchRoom(offers[i].first, offers[i].second, bestOfferRoom, rooms); if(indexInsert != -1) bestOfferRoom[indexInsert] = offers[i].second; } for(int i = 0; i<n; ++i) { bestOfferRoom[i] += rooms[i].second; } sort(bestOfferRoom.rbegin(), bestOfferRoom.rend()); long long sum = 0; for(int i = 0; i<o; ++i) { sum += max(0l,bestOfferRoom[i]); } cout<<sum<<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 20 ms | 880 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 73 ms | 3332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 134 ms | 5700 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 430 ms | 15756 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 878 ms | 31280 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 937 ms | 36088 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |