제출 #1136222

#제출 시각아이디문제언어결과실행 시간메모리
1136222newbai학교 설립 (IZhO13_school)C++20
15 / 100
128 ms20892 KiB
#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef pair<ll, int> 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 timeMemoryGrader output
Fetching results...