#include<bits/stdc++.h>
using namespace std;
struct xy{
int x;
int y;
};
int n,m,s;
bool sort21(xy a,xy b){
return a.x>b.x;
}
int cnt1;
int u1[300001],u2[300001];
int main(){
int n,m,s;
cin>>n>>m>>s;
xy a[n+1],b[n+1];
for(int i=1;i<=n;i++){
cin>>a[i].x>>b[i].x;
a[i].y=i;
b[i].y=i;
}
sort(a+1,a+1+n,sort21);
sort(b+1,b+1+n,sort21);
for(int i=1;i<=m;i++){
cnt1+=a[i].x;
u1[a[i].y]++;
}
int j=1;
for(int i=1;i<=n;i++){
if(j>s)
break;
if(u1[b[i].y]==0){
cnt1+=b[i].x;
j++;
}
}
int cnt2=0;
for(int k=1;k<=s;k++){
cnt2+=b[k].x;
u2[b[k].y]=1;
}
j=1;
for(int k=1;k<=n;k++){
if(j>m)
break;
if(u2[a[k].y]==0){
cnt2+=a[k].x;
j++;
}
}
cout<<max(cnt1,cnt2);
return 0;
}
Compilation message
school.cpp: In function 'int main()':
school.cpp:32:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(j>s)
^~
school.cpp:35:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
if(u1[b[i].y]==0){
^~
school.cpp:49:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(j>m)
^~
school.cpp:52:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
if(u2[a[k].y]==0){
^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Incorrect |
2 ms |
468 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
468 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
468 KB |
Output isn't correct |
7 |
Incorrect |
6 ms |
476 KB |
Output isn't correct |
8 |
Incorrect |
6 ms |
492 KB |
Output isn't correct |
9 |
Incorrect |
6 ms |
508 KB |
Output isn't correct |
10 |
Incorrect |
7 ms |
620 KB |
Output isn't correct |
11 |
Incorrect |
7 ms |
620 KB |
Output isn't correct |
12 |
Incorrect |
6 ms |
680 KB |
Output isn't correct |
13 |
Incorrect |
38 ms |
1360 KB |
Output isn't correct |
14 |
Incorrect |
73 ms |
2384 KB |
Output isn't correct |
15 |
Correct |
145 ms |
3904 KB |
Output is correct |
16 |
Incorrect |
166 ms |
4780 KB |
Output isn't correct |
17 |
Incorrect |
209 ms |
5700 KB |
Output isn't correct |
18 |
Incorrect |
220 ms |
6220 KB |
Output isn't correct |
19 |
Incorrect |
308 ms |
6620 KB |
Output isn't correct |
20 |
Incorrect |
275 ms |
7800 KB |
Output isn't correct |