답안 #13215

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
13215 2015-02-03T08:46:59 Z dohyun0324 학교 설립 (IZhO13_school) C++
5 / 100
124 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;
    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 Incorrect 0 ms 5096 KB Output isn't 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 2 ms 5096 KB Output isn't correct
8 Incorrect 3 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 0 ms 5096 KB Output isn't correct
13 Incorrect 16 ms 5240 KB Output isn't correct
14 Incorrect 37 ms 5484 KB Output isn't correct
15 Incorrect 63 ms 6636 KB Output isn't correct
16 Incorrect 63 ms 5228 KB Output isn't correct
17 Incorrect 97 ms 6000 KB Output isn't correct
18 Incorrect 97 ms 6636 KB Output isn't correct
19 Incorrect 103 ms 6128 KB Output isn't correct
20 Incorrect 124 ms 6636 KB Output isn't correct