답안 #635108

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
635108 2022-08-25T12:29:47 Z pragmatist 학교 설립 (IZhO13_school) C++17
20 / 100
141 ms 11792 KB
#include<bits/stdc++.h>
 
#define ll long long
#define pb push_back
#define x first
#define y second
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ld long double              
#define nl "\n"

using namespace std;
using pii = pair<int, int>;
 
const int N = (int)3e5 + 7;
const int inf = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
const int MOD = (int)1e9 + 7;
const int M = (int)5e4 + 7; 

int n, m, s, a[N], b[N];
bool used[N];

void solve() {
	cin >> n >> m >> s;
	vector<pair<pii, int> > v;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i] >> b[i];
		v.pb({{a[i], -b[i]}, i});
	}
	sort(rall(v));
	ll A = 0, B = 0;
	for(int i = 0; i < m; ++i) {
		A += v[i].x.x;
		used[v[i].y] = 1;
	}        
	v.clear();
	for(int i = 1; i <= n; ++i) {
		if(used[i]) continue;
		v.pb({{b[i], 0}, 0});
	}
	sort(rall(v));
	for(int i = 0; i < s; ++i)
		A += v[i].x.x;

	v.clear();
	memset(used, 0, sizeof(used));
	
	for(int i = 1; i <= n; ++i) {
		v.pb({{b[i], -a[i]}, i});
	}
	sort(rall(v));
	for(int i = 0; i < s; ++i) {
		B += v[i].x.x;
		used[v[i].y] = 1;
	}
	v.clear();
	for(int i = 1; i <= n; ++i) {
		if(used[i]) continue;
		v.pb({{a[i], 0}, 0});
	}
	sort(rall(v));
	for(int i = 0; i < m; ++i)
		B += v[i].x.x;

	cout << max(A, B) << nl;
}
 
int main() {
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
	cout.tie(0);
	int test = 1;
	//cin >> test;
	while(test--) {
		solve();
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 0 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Incorrect 1 ms 596 KB Output isn't correct
5 Incorrect 0 ms 596 KB Output isn't correct
6 Incorrect 1 ms 596 KB Output isn't correct
7 Incorrect 2 ms 724 KB Output isn't correct
8 Incorrect 3 ms 724 KB Output isn't correct
9 Incorrect 2 ms 784 KB Output isn't correct
10 Incorrect 3 ms 740 KB Output isn't correct
11 Incorrect 3 ms 724 KB Output isn't correct
12 Incorrect 3 ms 724 KB Output isn't correct
13 Incorrect 20 ms 1744 KB Output isn't correct
14 Incorrect 40 ms 3372 KB Output isn't correct
15 Correct 87 ms 6116 KB Output is correct
16 Incorrect 82 ms 6116 KB Output isn't correct
17 Incorrect 101 ms 7480 KB Output isn't correct
18 Incorrect 115 ms 8256 KB Output isn't correct
19 Incorrect 119 ms 8760 KB Output isn't correct
20 Incorrect 141 ms 11792 KB Output isn't correct