# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
870923 | anha3k25cvp | Schools (IZhO13_school) | C++14 | 98 ms | 8444 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |