# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
875447 |
2023-11-19T17:43:35 Z |
gutzzy |
Hotel (CEOI11_hot) |
C++17 |
|
4000 ms |
8580 KB |
#include <bits/stdc++.h>
using namespace std;
int n,m,o,profit;
pair<int,int> best_room(vector<pair<int,int>> &rooms, pair<int,int> of, vector<bool> &used){
int bestr = -1;
int bestp = 1e9 + 7;
for(int i=0;i<n;i++){
if(used[i]) continue;
pair<int,int> room = rooms[i];
if(room.second>=of.second and room.first<=bestp){
if(room.first<bestp or bestr==-1){
bestp = room.first;
bestr = i;
}
else{
if(room.second<rooms[bestr].second){
bestp = room.first;
bestr = i;
}
}
}
}
return {of.first-bestp,bestr};
}
int main(){
profit = 0;
cin >> n >> m >> o;
vector<pair<int,int>> rooms(n);
vector<bool> used(n, false);
vector<pair<int,int>> ofertas(m);
for(int i=0;i<n;i++) cin >> rooms[i].first >> rooms[i].second;
for(int i=0;i<m;i++) cin >> ofertas[i].first >> ofertas[i].second;
priority_queue<pair<pair<int,int>,int>> pq;
for(int xx=0;xx<m;xx++){
pair<int,int> of = ofertas[xx];
pq.push({best_room(rooms, of, used),xx});
}
while(o>0 and !pq.empty()){
pair<pair<int,int>,int> p = pq.top();
pq.pop();
if(p.first.second==-1 or p.first.first<=0) continue;
//cout << p.first.first << " " << p.first.second << " " << p.second << endl;
if(used[p.first.second]){
pq.push({best_room(rooms,ofertas[p.second], used),p.second});
}
else{
profit += p.first.first;
used[p.first.second] = true;
}
o--;
}
cout << profit << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
223 ms |
688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4062 ms |
1844 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4032 ms |
2324 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4046 ms |
3856 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4008 ms |
7248 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4033 ms |
8580 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |