#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' <<
#define nl << '\n'
signed main(){
cin.tie(0)->sync_with_stdio(0);
int n, m, o; cin >> n >> m >> o;
array<int, 2> offers[m], room;
multiset<array<int, 2>> rooms;
for(int i=0; i<n; ++i){
cin >> room[1] >> room[0];
rooms.insert(room);
}
for(auto &i : offers) cin >> i[0] >> i[1];
sort(offers, offers+m, greater<>());
vector<int> pos;
for(auto &i : offers){
auto f = rooms.lower_bound({i[1], 0});
if(f != rooms.end()){
pos.push_back(i[0] - (*f)[1]);
rooms.erase(f);
}
}
sort(pos.begin(), pos.end(), greater<>());
int ans = 0;
for(int i=0; i<min(o, (int)pos.size()); ++i){
if(pos[i]>0) ans += pos[i];
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
4208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
7016 KB |
Output is correct |
2 |
Correct |
80 ms |
7660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
362 ms |
18252 KB |
Output is correct |
2 |
Correct |
168 ms |
14052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
803 ms |
35932 KB |
Output is correct |
2 |
Correct |
976 ms |
35940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
932 ms |
43868 KB |
Output is correct |
2 |
Correct |
1067 ms |
43868 KB |
Output is correct |
3 |
Correct |
1322 ms |
60252 KB |
Output is correct |