# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
875417 |
2023-11-19T15:48:51 Z |
lalig777 |
Hotel (CEOI11_hot) |
C++14 |
|
700 ms |
26452 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
int n, m, o;
priority_queue<int>pq;
cin>>n>>m>>o;
vector<pair<int,int> >habitacions(n);
vector<int>max_prof(n, 0);
vector<pair<int,int> >offers(m);
for (int i=0; i<n; i++) cin>>habitacions[i].first>>habitacions[i].second;
sort(habitacions.begin(), habitacions.end());
for (int i=0; i<m; i++) cin>>offers[i].second>>offers[i].first;
sort(offers.begin(), offers.end());
int k=0;
for (int i=0; i<n; i++){
int max_people=habitacions[i].second;
for (int j=k; j<m; j++){
if (offers[j].first<=max_people) pq.push(offers[j].second);
else{
k=j;
break;
}if (j==m-1) k=m;
}if (!pq.empty()){
max_prof[i]=max(0, pq.top()-habitacions[i].first);
pq.pop();
}
}sort(max_prof.begin(), max_prof.end());
long long int ans=0;
for (int i=n-1; i>=n-o; i--) ans+=max_prof[i];
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
1216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
1628 KB |
Output is correct |
2 |
Correct |
65 ms |
3156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
275 ms |
4356 KB |
Output is correct |
2 |
Correct |
154 ms |
6860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
550 ms |
8272 KB |
Output is correct |
2 |
Correct |
552 ms |
8276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
666 ms |
10468 KB |
Output is correct |
2 |
Correct |
700 ms |
10336 KB |
Output is correct |
3 |
Correct |
621 ms |
26452 KB |
Output is correct |