답안 #210118

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210118 2020-03-16T15:04:44 Z mr_stefan Hotel (CEOI11_hot) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <set>

using namespace std;

const int VAL=500005;

int N, M, NRO, i, j;
int dif[VAL];
long long ANS;

struct camera
{
    int cost, cap;
};

camera C[VAL], A;

bool operator < (const camera &X, const camera &Y)
{
    if (X.cap!=Y.cap)
        return X.cap<Y.cap;
    return X.cost<Y.cost;
}

set <camera> H;
set <camera> :: iterator it;

struct oferta
{
    int pret, dim;
};

oferta O[VAL];

bool cmpO(oferta A, oferta B)
{
    return A.pret>B.pret;
}

int main()
{
    cin >> N >> M >> NRO;
    for (i=1; i<=N; i++)
    {
        cin >> C[i].cost >> C[i].cap;
        H.insert(C[i]);
    }
    for (i=1; i<=M; i++)
        cin >> O[i].pret >> O[i].dim;
    sort(O+1, O+M+1, cmpO);
    for (i=1; i<=M; i++)
    {
        A.cost=0;
        A.cap=O[i].dim;
        it=H.upper_bound(A);
        if (it==H.end())
            continue;
        A=*it;
        dif[i]=O[i].pret-A.cost;
        H.erase(it);
        //cout << O[i].pret << " " << A.cost << '\n';
    }
    sort(dif+1, dif+M+1);
    for (i=M; i>M-NRO; i--)
        if (dif[i]>0)
            ANS+=dif[i];
    cout << ANS << '\n';
    return 0;
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:51:5: error: 'sort' was not declared in this scope
     sort(O+1, O+M+1, cmpO);
     ^~~~
hot.cpp:51:5: note: suggested alternative: 'qsort'
     sort(O+1, O+M+1, cmpO);
     ^~~~
     qsort