#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];
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;
}
sort(tab, tab+n);
vector<pii> v(m);
for(int i=0;i<m;i++) {
cin >> v[i].st >> v[i].nd;
}
sort(all(v));
vector<int> ans;
for(pii x:v) {
for(int i=0;i<n;i++) {
if(!vis[i]&&tab[i].nd>=x.nd&&tab[i].st<x.st) {
ans.pb(-(x.st-tab[i].st));
vis[i] = true;
break;
}
}
}
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 |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
69 ms |
892 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1058 ms |
3460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3159 ms |
5412 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4019 ms |
8800 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4022 ms |
14904 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4022 ms |
18288 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |