#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,s;
ll cnt,cnt1,r,r1;
struct xy{
ll x;
ll y;
ll z;
};
bool sort21(xy a,xy b){
return a.x>b.x;
}
bool sort211(xy a,xy b){
return a.y>b.y;
}
xy f[300001];
xy f1[300001];
int main(){
cin>>n>>m>>s;
for(int k=1;k<=n;k++){
cin>>f[k].x>>f[k].y;
f1[k].x=f[k].x;
f1[k].y=f[k].y;
f1[k].z=0;
f[k].z=0;
}
sort(f+1,f+n+1,sort21);
for(int k=1;k<=m;k++){
cnt+=f[k].x;
f[k].z=1;
}
sort(f+1,f+n+1,sort211);
for(int k=1;k<=n;k++){
if(r<s){
if(f[k].z!=1){
cnt+=f[k].y;
f[k].z=1;
r++;
}
}
else break;
}
sort(f1+1,f1+n+1,sort211);
for(int k=1;k<=s;k++){
cnt1+=f1[k].y;
f1[k].z=1;
}
sort(f1+1,f1+n+1,sort21);
for(int k=1;k<=n;k++){
if(r1<m){
if(f1[k].z!=1){
cnt1+=f[k].x;
f1[k].z=1;
r1++;
}
}
else break;
}
cout<<max(cnt,cnt1);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Incorrect |
3 ms |
556 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
556 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
636 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
636 KB |
Output isn't correct |
7 |
Incorrect |
7 ms |
700 KB |
Output isn't correct |
8 |
Incorrect |
8 ms |
736 KB |
Output isn't correct |
9 |
Incorrect |
8 ms |
864 KB |
Output isn't correct |
10 |
Incorrect |
8 ms |
864 KB |
Output isn't correct |
11 |
Incorrect |
8 ms |
864 KB |
Output isn't correct |
12 |
Incorrect |
8 ms |
864 KB |
Output isn't correct |
13 |
Incorrect |
51 ms |
2276 KB |
Output isn't correct |
14 |
Incorrect |
114 ms |
4320 KB |
Output isn't correct |
15 |
Incorrect |
225 ms |
8172 KB |
Output isn't correct |
16 |
Incorrect |
262 ms |
9068 KB |
Output isn't correct |
17 |
Incorrect |
294 ms |
10856 KB |
Output isn't correct |
18 |
Incorrect |
314 ms |
12032 KB |
Output isn't correct |
19 |
Incorrect |
338 ms |
12796 KB |
Output isn't correct |
20 |
Incorrect |
418 ms |
14588 KB |
Output isn't correct |