#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
pii tab[500009];
bool vis[500009];
multiset<pii> S;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, o;
cin >> n >> m >> o;
for(int i=0;i<n;i++) {
cin >> tab[i].st >> tab[i].nd;
S.insert({tab[i].nd, tab[i].st});
}
vector<pii> v(m);
for(int i=0;i<m;i++) {
cin >> v[i].st >> v[i].nd;
v[i].st*=-1;
}
sort(all(v));
vector<int> ans;
for(pii x:v) {
x.st = -x.st;
auto it = S.upper_bound({x.nd, -1});
if(it!=S.end()) {
int val = (*it).nd;
if(val<x.st) {
ans.pb(-(x.st-val));
}
S.erase(it);
}
}
int res = 0;
sort(all(ans));
for(int i=0;i<min(sz(ans), o);i++) {
res -= ans[i];
}
cout << res << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
7452 KB |
Output is correct |
2 |
Correct |
71 ms |
6724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
273 ms |
21400 KB |
Output is correct |
2 |
Correct |
118 ms |
15588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
603 ms |
42088 KB |
Output is correct |
2 |
Correct |
778 ms |
53232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
735 ms |
51568 KB |
Output is correct |
2 |
Correct |
825 ms |
70676 KB |
Output is correct |
3 |
Correct |
1060 ms |
67860 KB |
Output is correct |