Submission #88950

# Submission time Handle Problem Language Result Execution time Memory
88950 2018-12-10T06:55:17 Z Lkvatashidze Schools (IZhO13_school) C++17
10 / 100
169 ms 29692 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

     pair < ll, ll > a[300005];
     pair < ll, ll > b[300005];
     ll used[300005];
     ll n, m, s;
     ll ans, ans0;

 int main() {

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

    cin >> n >> m >> s;

    for (ll k=1; k<=n; k++) {
        ll x, y;
        cin >> x >> y;
        a[k].first=x;
        a[k].second=k;
        b[k].first=y;
        b[k].second=k;
    }

    sort (a+1,a+1+n);
    sort (b+1,b+1+n);

    for (ll k=n; k>=n-m+1; k--) {
        ans+=a[k].first;
        used[a[k].second]=true;
    }

    reverse(b+1,b+1+n);

    ll i=1; ll j=1;
     while (i<=s && j<=n) {
        if (used[b[j].second]) {
            j++;
            continue;
        }
        ans+=b[j].first;
        used[b[j].second]=true;
        j++; i++;
     }

   for (ll k=1; k<=n; k++)
     used[k]=false;

    sort (a+1,a+1+n);
    sort (b+1,b+1+n);

    for (ll k=n; k>=n-s+1; k--) {
        ans0+=b[k].first;
        used[b[k].second]=true;
    }

    reverse(a+1,a+1+n);

     i=1; j=1;
     while (i<=m && j<=n) {
        if (used[a[j].second]) {
            j++;
            continue;
        }
        ans0+=a[j].first;
        used[b[j].second]=true;
        j++; i++;
     }

      cout << max(ans,ans0);

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 416 KB Output isn't correct
4 Incorrect 2 ms 468 KB Output isn't correct
5 Incorrect 2 ms 472 KB Output isn't correct
6 Incorrect 2 ms 524 KB Output isn't correct
7 Incorrect 4 ms 784 KB Output isn't correct
8 Incorrect 4 ms 836 KB Output isn't correct
9 Incorrect 4 ms 916 KB Output isn't correct
10 Incorrect 4 ms 1020 KB Output isn't correct
11 Incorrect 4 ms 1184 KB Output isn't correct
12 Incorrect 4 ms 1184 KB Output isn't correct
13 Incorrect 19 ms 2720 KB Output isn't correct
14 Incorrect 41 ms 5168 KB Output isn't correct
15 Correct 82 ms 10256 KB Output is correct
16 Incorrect 98 ms 13056 KB Output isn't correct
17 Incorrect 117 ms 17144 KB Output isn't correct
18 Incorrect 132 ms 20752 KB Output isn't correct
19 Incorrect 141 ms 24608 KB Output isn't correct
20 Incorrect 169 ms 29692 KB Output isn't correct