#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
#define fi first
#define se second
#define mask(i) (1LL << (i))
const int N = 3e5 + 5;
int n, m, s;
ii a[N];
map<ii, int> mp;
bool cmp1(const ii& a, const ii& b) { return (a.fi - a.se) < (b.fi - b.se); }
bool cmp2(const ii& a, const ii& b) { return a.se > b.se; }
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin >> n >> m >> s;
priority_queue<ii, vector<ii>, decltype(&cmp1)> q(cmp1);
for (int i = 1; i <= n; i ++) {
cin >> a[i].fi >> a[i].se;
q.push(a[i]);
}
ll res = 0;
while (m > 0) {
res += q.top().fi;
//cout << q.top().fi << " " << q.top().se << endl;
mp[q.top()] = -1;
q.pop();
m --;
}
sort(a + 1, a + n + 1, cmp2);
for (int i = 1; s > 0 && i <= n; i ++) {
if (mp[a[i]] == 0) res += a[i].se;
s--;
}
cout << res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |