Submission #108448

# Submission time Handle Problem Language Result Execution time Memory
108448 2019-04-29T17:21:22 Z Frankenween Schools (IZhO13_school) C++17
25 / 100
114 ms 15468 KB
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define ull unsigned long long
#define pll pair<ll, ll>
#define mp make_pair
#define ll long long
#define pb push_back
#define deb(x) cout << #x << " = " << x << endl
#define all(x) x.begin(), x.end()
#define ld long double
const ll mod1 = (ll)1e9 + 7;
const ll mod2 = (ll)1e9 + 9;
const ll BASE = 47;
const ll inf = (ll)1e18;
const long double e = 2.718281828459;
const long double pi = 3.141592653;
const ld EPS = 1e-9;


using namespace std;


template <class T>
istream& operator>>(istream &in, vector<T> &arr) {
    for (T &cnt : arr) {
        in >> cnt;
    }
    return in;
};


void solve() {
    ll n, m, s;
    cin >> n >> m >> s;
    vector<ll> a(n), b(n);
    vector<pair<ll, ll>> d(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        d[i] = {b[i] - a[i], i};
    }
    vector<bool> put_b(n);
    sort(all(d));
    ll answer = 0;
    for (int i = 0; i < s; i++) {
        put_b[d[n - i - 1].second] = true;
        answer += b[d[n - i - 1].second];
    }
    vector<ll> put_a;
    for (int i = 0; i < n; i++) {
        if (!put_b[i]) {
            put_a.pb(a[i]);
        }
    }
    sort(all(put_a));
    for (int i = 0; i < m; i++) {
        answer += put_a.back();
        put_a.pop_back();
    }
    cout << answer;
}


int main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#else
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout.precision(30);
    ll seed = time(0);
    //cerr << "Seed: " << seed << "\n";
    srand(seed);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Incorrect 0 ms 256 KB Output isn't correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Incorrect 3 ms 384 KB Output isn't correct
7 Incorrect 5 ms 640 KB Output isn't correct
8 Correct 5 ms 640 KB Output is correct
9 Incorrect 5 ms 640 KB Output isn't correct
10 Incorrect 5 ms 640 KB Output isn't correct
11 Incorrect 4 ms 640 KB Output isn't correct
12 Incorrect 4 ms 512 KB Output isn't correct
13 Incorrect 16 ms 2560 KB Output isn't correct
14 Incorrect 31 ms 4372 KB Output isn't correct
15 Incorrect 80 ms 9300 KB Output isn't correct
16 Correct 62 ms 8312 KB Output is correct
17 Incorrect 82 ms 10996 KB Output isn't correct
18 Incorrect 97 ms 12912 KB Output isn't correct
19 Incorrect 108 ms 13808 KB Output isn't correct
20 Incorrect 114 ms 15468 KB Output isn't correct