# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1149008 | uasdfae | Schools (IZhO13_school) | C++17 | 1 ms | 328 KiB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
#define fi first
#define se second
#define mask(i) (1LL << (i))
const int N = 1e3 + 5;
const ll inf = 1e17;
int k, n, m;
ii a[N];
bool cmp(ii a, ii b) { return a.fi - a.se > b.fi - b.se; }
bool cmp2(ii a, ii b) { return a.se > b.se; }
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
freopen("school.in", "r", stdin);
freopen("school.out", "w", stdout);
cin >> k >> n >> m;
for (int i = 1; i <= k; i++) cin >> a[i].fi >> a[i].se;
sort(a + 1, a + k + 1, cmp);
ll res = 0;
for (int i = 1; i <= n; i++) {
res += a[i].fi;
a[i].se = -1;
}
sort(a + 1, a + k + 1, cmp2);
for (int i = 1; i <= m; i++) res += a[i].se;
cout << res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |