# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
99518 | Miyukine | 학교 설립 (IZhO13_school) | C++14 | 140 ms | 9720 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|---|---|---|---|
Fetching results... |