Submission #211801

#TimeUsernameProblemLanguageResultExecution timeMemory
211801MarcVanaHotel (CEOI11_hot)C++14
100 / 100
2003 ms53060 KiB
#include <iostream> #include <algorithm> #include <set> #define NMAX 500005 using namespace std; int N, M, NRO; int DIFF[NMAX]; long long ANS; struct room { int cost, capacity; } C[NMAX], A; multiset <room> H; multiset <room> :: iterator it; bool operator < (const room &X, const room &Y) { if (X.capacity != Y.capacity) return X.capacity < Y.capacity; return X.cost < Y.cost; } struct offer { int price, dimension; } O[NMAX]; bool cmpO(offer A, offer B) { return A.price>B.price; } int main() { cin >> N >> M >> NRO; for (int i=1; i<=N; i++) { cin >> C[i].cost >> C[i].capacity; H.insert(C[i]); } for (int i=1; i<=M; i++) cin >> O[i].price >> O[i].dimension; sort(O+1, O+M+1, cmpO); for (int i=1; i<=M; i++) { A.cost=0; A.capacity=O[i].dimension; it=H.upper_bound(A); if (it==H.end()) continue; A=*it; DIFF[i]=O[i].price-A.cost; H.erase(it); } sort(DIFF+1, DIFF+M+1); for (int i=M; i>M-NRO; i--) if (DIFF[i]>0) ANS+=DIFF[i]; cout << ANS; 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...