#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mxN=5e5;
int n, m, o, c[mxN], p[mxN], p2[mxN], a[mxN];
vector<int> va[mxN], vb[mxN+1];
priority_queue<int> pq;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> o;
for(int i=0; i<n; ++i)
cin >> c[i] >> p[i];
memcpy(p2, p, 4*n);
sort(p2, p2+n);
for(int i=0; i<n; ++i) {
p[i]=lower_bound(p2, p2+n, p[i])-p2;
va[p[i]].push_back(c[i]);
}
for(int i=0, d, v; i<m; ++i) {
cin >> d >> v;
vb[lower_bound(p2, p2+n, v)-p2].push_back(d);
}
for(int i=0; i<n; ++i)
sort(va[i].begin(), va[i].end());
for(int i=0, k=0; i<n; ++i) {
for(int b : vb[i])
pq.push(b);
for(int j=0; j<va[i].size()&&pq.size()&&pq.top()>va[i][j]; ++j) {
a[k++]=pq.top()-va[i][j];
pq.pop();
}
}
nth_element(a, a+o, a+min(n, m));
cout << accumulate(a, a+o, 0ll);
}
Compilation message
hot.cpp: In function 'int main()':
hot.cpp:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0; j<va[i].size()&&pq.size()&&pq.top()>va[i][j]; ++j) {
~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
23936 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
23928 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
23800 KB |
Output is correct |
2 |
Incorrect |
22 ms |
23936 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
23796 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
24568 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
60 ms |
26712 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
28696 KB |
Output is correct |
2 |
Incorrect |
66 ms |
27384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
205 ms |
37140 KB |
Output is correct |
2 |
Incorrect |
113 ms |
30704 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
405 ms |
50784 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
395 ms |
53852 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |