답안 #13216

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
13216 2015-02-03T11:11:01 Z dohyun0324 학교 설립 (IZhO13_school) C++
10 / 100
143 ms 6636 KB
#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;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;
    if(dap<sum) dap=sum;
    for(i=1;i<=s;i++)
    {
        if(q.size()==0 || q.top()+a[p2].x<q2.top())
        {
            sum+=q2.top(); p--;
            q2.pop(); q2.push(a[p].y);
        }
        else
        {
            sum+=q.top()+a[p2].x; p2++;
            q.pop();
        }
        if(dap<sum) dap=sum;
    }
    printf("%d",dap);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 5096 KB Output isn't correct
2 Correct 0 ms 5096 KB Output is correct
3 Correct 0 ms 5096 KB Output is correct
4 Incorrect 0 ms 5096 KB Output isn't correct
5 Incorrect 0 ms 5096 KB Output isn't correct
6 Incorrect 0 ms 5096 KB Output isn't correct
7 Incorrect 0 ms 5096 KB Output isn't correct
8 Incorrect 0 ms 5096 KB Output isn't correct
9 Incorrect 0 ms 5096 KB Output isn't correct
10 Incorrect 0 ms 5096 KB Output isn't correct
11 Incorrect 0 ms 5096 KB Output isn't correct
12 Incorrect 1 ms 5096 KB Output isn't correct
13 Incorrect 13 ms 5240 KB Output isn't correct
14 Incorrect 29 ms 5484 KB Output isn't correct
15 Incorrect 75 ms 6636 KB Output isn't correct
16 Incorrect 66 ms 5228 KB Output isn't correct
17 Incorrect 95 ms 6000 KB Output isn't correct
18 Incorrect 118 ms 6636 KB Output isn't correct
19 Incorrect 89 ms 6128 KB Output isn't correct
20 Incorrect 143 ms 6636 KB Output isn't correct