Submission #13214

#TimeUsernameProblemLanguageResultExecution timeMemory
13214dohyun0324Schools (IZhO13_school)C++98
0 / 100
126 ms6636 KiB
#include<stdio.h> #include<queue> #include<algorithm> using namespace std; int sum,dap,n,m,s,p,ch[300010],p2; priority_queue<int>q; priority_queue<int>q2; struct data{ int x,y; bool operator<(const data&r)const{ return x>r.x; } }a[300010]; int main() { int i; scanf("%d %d %d",&n,&m,&s); for(i=1;i<=n;i++) { scanf("%d %d",&a[i].x,&a[i].y); } sort(a+1,a+n+1); p=m+s; for(i=n;i>=p+1;i--) q2.push(a[i].y); for(i=1;i<=m;i++) q.push(a[i].y-a[i].x), sum+=a[i].x; p2=m+1; for(i=1;i<=s;i++) { if(q.top()+a[p2].x<=q2.top()) { sum+=q2.top(); p--; q2.pop(); q2.push(a[p+1].y); } else { sum+=q.top()+a[p2].x; p2++; q.pop(); } if(dap<sum) dap=sum; } printf("%d",dap); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...