Submission #88949

# Submission time Handle Problem Language Result Execution time Memory
88949 2018-12-10T06:53:33 Z Lkvatashidze Schools (IZhO13_school) C++17
0 / 100
5 ms 844 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() {

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

    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;
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:13:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen ("school.in", "r", stdin);
     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:14:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen ("school.out", "w", stdout);
     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Incorrect 4 ms 500 KB Output isn't correct
3 Incorrect 4 ms 552 KB Output isn't correct
4 Incorrect 4 ms 600 KB Output isn't correct
5 Incorrect 4 ms 600 KB Output isn't correct
6 Incorrect 4 ms 604 KB Output isn't correct
7 Incorrect 4 ms 620 KB Output isn't correct
8 Incorrect 4 ms 624 KB Output isn't correct
9 Incorrect 4 ms 660 KB Output isn't correct
10 Incorrect 4 ms 660 KB Output isn't correct
11 Incorrect 4 ms 676 KB Output isn't correct
12 Incorrect 4 ms 676 KB Output isn't correct
13 Incorrect 4 ms 680 KB Output isn't correct
14 Incorrect 5 ms 716 KB Output isn't correct
15 Incorrect 4 ms 716 KB Output isn't correct
16 Incorrect 4 ms 716 KB Output isn't correct
17 Incorrect 4 ms 716 KB Output isn't correct
18 Incorrect 4 ms 844 KB Output isn't correct
19 Incorrect 4 ms 844 KB Output isn't correct
20 Incorrect 3 ms 844 KB Output isn't correct