Submission #1149023

#TimeUsernameProblemLanguageResultExecution timeMemory
1149023uasdfaeSchools (IZhO13_school)C++17
25 / 100
59 ms5000 KiB
#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;
const ll inf = 1e17;

int k, n, m;
ii a[N];

bool cmp(ii a, ii b) { return a.fi - a.se > b.fi - b.se; }
bool cmp2(ii a, ii b) { return a.se > b.se; }


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    //freopen("school.in", "r", stdin);
    //freopen("school.out", "w", stdout);

    cin >> k >> n >> m;
    for (int i = 1; i <= k; i++) cin >> a[i].fi >> a[i].se;

    sort(a + 1, a + k + 1, cmp);
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        res += a[i].fi;
        a[i].se = -1;
    }

    sort(a + 1, a + k + 1, cmp2);
    for (int i = 1; i <= m; i++) res += a[i].se;
    cout << res;

}
#Verdict Execution timeMemoryGrader output
Fetching results...