# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89128 | mate | Schools (IZhO13_school) | C++14 | 285 ms | 14572 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;
struct xyz{
long long int x;
long long int y;
};
bool for_sort(xyz forsort1,xyz forsort2){
return forsort1.x>forsort2.x;
}
xyz a[300001],b[300001],mx,q[300001];
int main(){
long long int n,m,s,i,ax,ay,bx,by,cnt=1;
cin>>n>>m>>s;
for( 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,for_sort);
sort(b+1,b+1+n,for_sort);
for(i=1;i<=m;i++){
mx.x+=a[i].x;
q[a[i].y].x++;
}
for(i=1;i<=n;i++){
if(cnt>s)
break;
by=b[i].y;
bx=b[i].x;
if(q[by].x==0){
mx.x+=bx;
cnt++;
}
}
for(i=1;i<=s;i++){
mx.y+=b[i].x;
q[b[i].y].y=1;
}
cnt=1;
for(i=1;i<=n;i++){
if(cnt>m)
break;
ay=a[i].y;
ax=a[i].x;
if(q[ay].y==0){
mx.y+=ax;
cnt++;
}
}
cout<<max(mx.x,mx.y);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |