Submission #725530

# Submission time Handle Problem Language Result Execution time Memory
725530 2023-04-17T15:03:07 Z vjudge1 Schools (IZhO13_school) C++17
5 / 100
107 ms 14644 KB
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;

const int N = 3*1e5+5;
using ll = long long;
using PI = pair<ll, ll>;
using PII = pair<PI, ll>;
bool vis[N];

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

    ios_base::sync_with_stdio(0); cin.tie(0);

    ll n, m, s; cin >> n >> m >> s;

    vector<PII> vp(n+10);
    for(ll i = 0; i < n; i++){
        cin >> vp[i].F.F >> vp[i].F.S;
        vp[i].S = i;
    }

    vector<PII> ord(n+10);
    for(ll i = 0; i < n; i++){
        ord[i].F.F = vp[i].F.F-vp[i].F.S;
        ord[i].F.S = vp[i].F.F;
        ord[i].S = i;
    }

    sort(ord.begin(), ord.end(), [&](PII a, PII b){
        if(a.F.F != b.F.F){
            return a.F.F > b.F.F;
        }
        return a.F.S > b.F.S;
    });

    ll ans = 0;
    ll indx = 0;

    while(m--){
        ans += vp[ord[indx].S].F.F;
        vis[ord[indx].S] = true;
        indx++;
    }

    sort(vp.begin(), vp.end(), [&](PII a, PII b){
        if(a.F.S != b.F.S){
            return a.F.S > b.F.S;
        }
        return a.F.F > b.F.F;
    });

    ll cnt = 0;
    ll i = 0;
    while(cnt != s && i != n-1){
        if(!vis[vp[i].S]){
            ans += vp[i].F.S;
            cnt++;
        }
        i++;
    }
    cout << ans <<"\n";

}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 2 ms 468 KB Output isn't correct
8 Incorrect 2 ms 468 KB Output isn't correct
9 Incorrect 2 ms 468 KB Output isn't correct
10 Incorrect 2 ms 468 KB Output isn't correct
11 Incorrect 2 ms 468 KB Output isn't correct
12 Incorrect 2 ms 468 KB Output isn't correct
13 Incorrect 17 ms 2036 KB Output isn't correct
14 Incorrect 25 ms 4000 KB Output isn't correct
15 Incorrect 56 ms 7768 KB Output isn't correct
16 Incorrect 62 ms 8904 KB Output isn't correct
17 Incorrect 77 ms 10700 KB Output isn't correct
18 Incorrect 83 ms 11736 KB Output isn't correct
19 Incorrect 91 ms 12680 KB Output isn't correct
20 Incorrect 107 ms 14644 KB Output isn't correct