Submission #89128

#TimeUsernameProblemLanguageResultExecution timeMemory
89128mateSchools (IZhO13_school)C++14
20 / 100
285 ms14572 KiB
#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 timeMemoryGrader output
Fetching results...