#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define REYNA(i,a,b) for(int i=(a);i<(b);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, pair <int, ll> > PP;
typedef pair <PII, int> PPI;
typedef pair <int, PII> PIP;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;
const int maxn = 1000100;
int taken[maxn];
PII A[maxn], B[maxn];
int n, a, b;
int main()
{
boost;
cin >> n >> a >> b;
FOR(i, 1, n) {
cin >> A[i].e1 >> B[i].e1;
A[i].e2 = B[i].e2 = i;
}
sort(A+1, A+n+1, greater<PII>());
sort(B+1, B+n+1, greater<PII>());
ll score = 0;
FOR(i, 1, a) {
score += A[i].e1;
taken[A[i].e2] = 1;
}
int bb = b;
FOR(i, 1, n) {
if (!taken[B[i].e2] && bb > 0) {
taken[B[i].e2] = 1;
bb--;
score += B[i].e1;
}
}
FOR(i, 1, n) taken[i] = 0;
ll sc = score; score = 0;
FOR(i, 1, n) swap(A[i], B[i]);
swap(a, b);
FOR(i, 1, a) {
score += A[i].e1;
taken[A[i].e2] = 1;
}
bb = b;
FOR(i, 1, n) {
if (!taken[B[i].e2] && bb > 0) {
taken[B[i].e2] = 1;
bb--;
score += B[i].e1;
}
}
cout << max(sc, score);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
428 KB |
Output isn't correct |
7 |
Incorrect |
4 ms |
512 KB |
Output isn't correct |
8 |
Incorrect |
4 ms |
512 KB |
Output isn't correct |
9 |
Incorrect |
4 ms |
512 KB |
Output isn't correct |
10 |
Incorrect |
5 ms |
512 KB |
Output isn't correct |
11 |
Incorrect |
5 ms |
512 KB |
Output isn't correct |
12 |
Incorrect |
5 ms |
512 KB |
Output isn't correct |
13 |
Incorrect |
17 ms |
1536 KB |
Output isn't correct |
14 |
Incorrect |
33 ms |
2808 KB |
Output isn't correct |
15 |
Correct |
72 ms |
5240 KB |
Output is correct |
16 |
Incorrect |
88 ms |
5884 KB |
Output isn't correct |
17 |
Incorrect |
105 ms |
7232 KB |
Output isn't correct |
18 |
Incorrect |
116 ms |
7928 KB |
Output isn't correct |
19 |
Incorrect |
113 ms |
8568 KB |
Output isn't correct |
20 |
Incorrect |
140 ms |
9720 KB |
Output isn't correct |