#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = array<int, 2>;
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
const int MAX = 1505;
int n, m, o;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> o;
vector<pi> c(n);
for (int i = 0; i < n; i++)
cin >> c[i][0] >> c[i][1];
sort(all(c));
vector<pi> d(m);
for (int i = 0; i < m; i++)
cin >> d[i][0] >> d[i][1];
sort(all(d));
vector<bool> a(n), b(m);
lint res = 0;
while (o--) {
int mx = (int) -1e9;
int x = 0, y = 0;
for (int i = 0; i < n; i++) {
if (a[i]) continue;
for (int j = 0; j < m; j++) {
if (b[j] || c[i][1] < d[j][1]) continue;
if (d[j][0] - c[i][0] > mx) {
mx = d[j][0] - c[i][0];
x = i;
y = j;
}
}
}
if (mx > 0) {
res += mx;
a[x] = true;
b[y] = true;
}
}
cout << res << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4102 ms |
856 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4030 ms |
2396 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4034 ms |
4096 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4019 ms |
11220 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4043 ms |
22092 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4041 ms |
24500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |