Submission #73825

# Submission time Handle Problem Language Result Execution time Memory
73825 2018-08-29T05:34:46 Z 윤교준(#2277) Schools (IZhO13_school) C++11
10 / 100
2000 ms 16112 KB
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const bool debug = 1;
const int MAXN = 300005;

int A[MAXN], B[MAXN];
bitset<MAXN> chk;

int N, CA, CB;

ll f(int X) {
	vector<pii> V;
	for(int i = 1; i <= N; i++) {
		V.eb(A[i]+X, -i);
		V.eb(B[i], i);
	}
	sorv(V); revv(V);

	ll ret = 0;
	int ca = 0, cb = 0;
	for(auto &v : V) {
		int idx = v.second;
		if(idx < 0) {
			idx = -idx;
			if(chk[idx] || ca == CA) continue;
			chk[idx] = true;
			ret += v.first - X;
			ca++;
		} else {
			if(chk[idx] || cb == CB) continue;
			chk[idx] = true;
			ret += v.first;
			cb++;
		}
	}
	return ret;
}

ll getAns() {
	ll ret = -INFLL;
	for(int x = -100005; x <= 100005; x++)
		upmax(ret, f(x));
	return ret;
}

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> CA >> CB;
	for(int i = 1; i <= N; i++) cin >> A[i] >> B[i];

	cout << getAns() << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 139 ms 376 KB Output isn't correct
2 Correct 123 ms 524 KB Output is correct
3 Correct 54 ms 524 KB Output is correct
4 Incorrect 938 ms 524 KB Output isn't correct
5 Incorrect 500 ms 616 KB Output isn't correct
6 Incorrect 1753 ms 616 KB Output isn't correct
7 Execution timed out 2037 ms 1204 KB Time limit exceeded
8 Execution timed out 2045 ms 1204 KB Time limit exceeded
9 Execution timed out 2051 ms 1204 KB Time limit exceeded
10 Execution timed out 2058 ms 1204 KB Time limit exceeded
11 Execution timed out 2037 ms 1204 KB Time limit exceeded
12 Execution timed out 2028 ms 1204 KB Time limit exceeded
13 Execution timed out 2040 ms 2616 KB Time limit exceeded
14 Execution timed out 2025 ms 4628 KB Time limit exceeded
15 Execution timed out 2051 ms 8568 KB Time limit exceeded
16 Execution timed out 2054 ms 9320 KB Time limit exceeded
17 Execution timed out 2047 ms 10156 KB Time limit exceeded
18 Execution timed out 2066 ms 10592 KB Time limit exceeded
19 Execution timed out 2048 ms 11140 KB Time limit exceeded
20 Execution timed out 2057 ms 16112 KB Time limit exceeded