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