#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) {
return (a.second - a.first) > (b.second - b.first);
}
int main() {
int n, m, s;
cin >> n >> m >> s;
multiset<pair<int, int>> left;
vector<pair<int, int>> schools;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
left.insert({ a*-1, b });
schools.push_back({ a, b });
}
sort(schools.begin(), schools.end(), comp);
int 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 |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Incorrect |
1 ms |
256 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 |
640 KB |
Output isn't correct |
8 |
Incorrect |
7 ms |
640 KB |
Output isn't correct |
9 |
Incorrect |
7 ms |
640 KB |
Output isn't correct |
10 |
Incorrect |
7 ms |
640 KB |
Output isn't correct |
11 |
Incorrect |
8 ms |
640 KB |
Output isn't correct |
12 |
Incorrect |
8 ms |
640 KB |
Output isn't correct |
13 |
Incorrect |
58 ms |
2804 KB |
Output isn't correct |
14 |
Incorrect |
142 ms |
5428 KB |
Output isn't correct |
15 |
Incorrect |
325 ms |
9972 KB |
Output isn't correct |
16 |
Incorrect |
433 ms |
11240 KB |
Output isn't correct |
17 |
Incorrect |
453 ms |
13288 KB |
Output isn't correct |
18 |
Incorrect |
509 ms |
14420 KB |
Output isn't correct |
19 |
Incorrect |
592 ms |
15460 KB |
Output isn't correct |
20 |
Incorrect |
661 ms |
17636 KB |
Output isn't correct |