# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
13214 | dohyun0324 | Schools (IZhO13_school) | C++98 | 126 ms | 6636 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<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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |