This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define rall(x) (x).rbegin(), (x).rend()
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, o; cin >> n >> m >> o;
multiset<pair<int, int>> room;
rep(i, 0, n) {
int p, c; cin >> c >> p;
room.insert({p, c});
}
vector<pair<int, int>> offer(m);
rep(i, 0, m) {
int v, d; cin >> v >> d;
offer[i] = {v, d};
}
sort(rall(offer));
vector<int> res;
for (auto [v, d] : offer) {
auto it = room.lower_bound({d, 0});
if (it == end(room)) continue;
res.push_back(v - it->second);
room.erase(it);
}
sort(rall(res)); int64_t ans = 0;
rep(i, 0, min(o, int(res.size()))) {
if (res[i] <= 0) break;
ans += res[i];
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |