# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89074 | beso123 | Schools (IZhO13_school) | C++14 | 344 ms | 7544 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n,m,s;
struct xy{
int x;
int y;
int 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;
}
int cnt=0,cnt1=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);
int r=0;
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);
int r1=0;
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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |