# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
249701 | srvlt | Schools (IZhO13_school) | C++14 | 117 ms | 2680 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int n0 = 3e5 + 123;
int n, m, s;
struct Pair {
int x, y;
bool operator < (const Pair & p) const {
if (x - y == p.x - p.y) return x > p.x;
return x - y > p.x - p.y;
}
};
Pair p[n0];
bool cmp(const Pair & a, const Pair & b) {
return a.y > b.y;
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
cin >> n >> m >> s;
for (int i = 0; i < n; i++) cin >> p[i].x >> p[i].y;
sort(p, p + n);
ll res = 0;
for (int i = 0; i < m; i++) res += p[i].x;
sort(p + m, p + n, cmp);
for (int i = m; i < m + s; i++) res += p[i].y;
cout << res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |