#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define ll long long
int n, m, s;
vector < pair < int, int > > v1, v2;
priority_queue < int > pq;
priority_queue < int > q;
ll count(vector < pair < int, int > > v, priority_queue < int > q)
{
ll res = 0;
for(int i = 0; i < m; i++)
{
res += v[i].fr;
}
for(int i = 0; i < s; i++)
{
res += q.top();
q.pop();
}
return res;
}
ll count1(vector < pair < int, int > > v, priority_queue < int > q)
{
ll res = 0;
for(int i = 0; i < m; i++)
{
res += q.top();
q.pop();
}
for(int i = 0; i < s; i++)
{
res += v[i].fr;
}
return res;
}
main()
{
cin >> n >> m >> s;
for(int i = 1; i <= n; i++)
{
int x, y;
cin >> x >> y;
v1.pb( { x, y } );
}
//puts("");
sort(v1.rbegin(), v1.rend());
for(int i = m; i < n; i++)
pq.push( v1[i].sc );
int ans1 = count(v1, pq);
for(int i = 0; i < n; i++)
swap(v1[i].fr, v1[i].sc);
//for(int i = 0; i < n; i++)
//cout << v1[i].fr << " " << v1[i].sc << endl;
//puts("");
sort(v1.rbegin(), v1.rend());
for(int i = s; i < n; i++)
q.push( v1[i].sc );//, cout << v1[i].sc << endl;
int ans2 = count1(v1, q);
cout << max(ans1, ans2);
}
/*
3 1 1
5 2
4 1
6 4
7 2 3
9 8
10 6
3 5
1 7
5 7
6 3
5 4
*/
Compilation message
school.cpp:53:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Incorrect |
2 ms |
460 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
492 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
7 |
Incorrect |
5 ms |
680 KB |
Output isn't correct |
8 |
Incorrect |
5 ms |
864 KB |
Output isn't correct |
9 |
Incorrect |
5 ms |
864 KB |
Output isn't correct |
10 |
Incorrect |
5 ms |
864 KB |
Output isn't correct |
11 |
Incorrect |
6 ms |
908 KB |
Output isn't correct |
12 |
Incorrect |
6 ms |
964 KB |
Output isn't correct |
13 |
Incorrect |
33 ms |
2388 KB |
Output isn't correct |
14 |
Incorrect |
65 ms |
4200 KB |
Output isn't correct |
15 |
Correct |
128 ms |
8648 KB |
Output is correct |
16 |
Incorrect |
165 ms |
9416 KB |
Output isn't correct |
17 |
Incorrect |
200 ms |
10012 KB |
Output isn't correct |
18 |
Incorrect |
212 ms |
11028 KB |
Output isn't correct |
19 |
Incorrect |
231 ms |
11392 KB |
Output isn't correct |
20 |
Incorrect |
269 ms |
12224 KB |
Output isn't correct |