Submission #870923

#TimeUsernameProblemLanguageResultExecution timeMemory
870923anha3k25cvpSchools (IZhO13_school)C++14
25 / 100
98 ms8444 KiB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dl double
#define st first
#define nd second
#define II pair <int, int>

using namespace std;

const int N = 5 + 1e5;
const int inf = 7 + 1e9;

int main() {
#define TASKNAME ""
    ios_base :: sync_with_stdio (0);
    cin.tie (0);
    if ( fopen( TASKNAME".inp", "r" ) ) {
        freopen (TASKNAME".inp", "r", stdin);
        freopen (TASKNAME".out", "w", stdout);
    }
    int n, m, s;
    cin >> n >> m >> s;
    int cnt = n - m - s;
    priority_queue <II> q;
    ll ans = 0;
    for (int i = 1; i <= n; i ++) {
        int x, y;
        cin >> x >> y;
        q.push({y - x, x});
        ans += (ll)x;
    }
    while (s --) {
        ans += (ll)q.top().st;
        q.pop();
    }
    priority_queue <int> p;
    while (!q.empty()) {
        p.push(-q.top().nd);
        q.pop();
    }
    while (cnt --) {
        ans += (ll)p.top();
        p.pop();
    }
    cout << ans;
    return 0;
}

Compilation message (stderr)

school.cpp: In function 'int main()':
school.cpp:19:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen (TASKNAME".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:20:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen (TASKNAME".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...