Submission #99518

#TimeUsernameProblemLanguageResultExecution timeMemory
99518MiyukineSchools (IZhO13_school)C++14
15 / 100
140 ms9720 KiB
#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 timeMemoryGrader output
Fetching results...