답안 #286277

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
286277 2020-08-30T09:02:45 Z shrek12357 학교 설립 (IZhO13_school) C++14
15 / 100
720 ms 26856 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
using namespace std;

#define ll long long

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
	return (a.second - a.first) > (b.second - b.first);
}

int main() {
	int n, m, s;
	cin >> n >> m >> s;
	multiset<pair<ll, ll>> left;
	vector<pair<ll, ll>> schools;
	for (int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		left.insert({ a*-1, b });
		schools.push_back({ a, b });
	}
	sort(schools.begin(), schools.end(), comp);
	ll ans = 0;
	for (int i = 0; i < m; i++) {
		ans += left.begin()->first*-1;
		left.erase(left.begin());
	}
	for (int i = 0; i < s; i++) {
		if (left.find({ schools[i].first*-1, schools[i].second }) != left.end()) {
			ans += schools[i].second;
		}
		else {
			ans += schools[i].second;
			ans -= schools[i].first;
			ans += left.begin()->first*-1;
			left.erase(left.begin());
		}
	}
	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Incorrect 1 ms 256 KB Output isn't correct
6 Incorrect 1 ms 384 KB Output isn't correct
7 Incorrect 7 ms 768 KB Output isn't correct
8 Incorrect 9 ms 768 KB Output isn't correct
9 Incorrect 7 ms 768 KB Output isn't correct
10 Incorrect 8 ms 768 KB Output isn't correct
11 Incorrect 8 ms 768 KB Output isn't correct
12 Incorrect 8 ms 768 KB Output isn't correct
13 Incorrect 62 ms 3828 KB Output isn't correct
14 Incorrect 145 ms 7272 KB Output isn't correct
15 Incorrect 326 ms 14396 KB Output isn't correct
16 Incorrect 443 ms 16232 KB Output isn't correct
17 Incorrect 517 ms 19292 KB Output isn't correct
18 Incorrect 566 ms 21096 KB Output isn't correct
19 Incorrect 627 ms 22500 KB Output isn't correct
20 Incorrect 720 ms 26856 KB Output isn't correct