#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>> cities(N);
for (int i = 0; i < N; i++) {
cin >> cities[i].first >> cities[i].second; // A_i, B_i
}
vector<int> idx(N);
iota(idx.begin(), idx.end(), 0);
sort(idx.begin(), idx.end(), [&](int a, int b) {
return max(cities[a].first, cities[a].second) > max(cities[b].first, cities[b].second);
});
idx.resize(M+S);
sort(idx.begin(), idx.end(), [&](int a, int b) {
return (cities[a].first - cities[a].second) > (cities[b].first - cities[b].second);
});
long long answer = 0;
for (int i = 0; i < M; i++) {
answer += cities[idx[i]].first;
}
for (int i = M; i < M+S; i++) {
answer += cities[idx[i]].second;
}
cout << answer << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |