#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, s;
cin >> n >> m >> s;
vector<pair<int, int>> c(n);
for (int i = 0; i < n; i++) cin >> c[i].first >> c[i].second;
vector<int> idx(n);
iota(idx.begin(), idx.end(), 0);
sort(idx.begin(), idx.end(), [&](int a, int b) {
return max(c[a].first, c[a].second) > max(c[b].first, c[b].second);
});
idx.resize(m + s);
sort(idx.begin(), idx.end(), [&](int a, int b) {
return (c[a].first - c[a].second) > (c[b].first - c[b].second);
});
long long ans = 0;
for (int i = 0; i < m; i++) ans += c[idx[i]].first;
for (int i = m; i < m + s; i++) ans += c[idx[i]].second;
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |