Submission #210121

# Submission time Handle Problem Language Result Execution time Memory
210121 2020-03-16T15:05:26 Z mr_stefan Hotel (CEOI11_hot) C++14
100 / 100
2253 ms 52864 KB
#include <iostream>
#include <algorithm>
#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;
}

multiset <camera> H;
multiset <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;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 131 ms 4600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 239 ms 7672 KB Output is correct
2 Correct 159 ms 6392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 718 ms 21360 KB Output is correct
2 Correct 327 ms 11316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1602 ms 42300 KB Output is correct
2 Correct 1826 ms 42520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1771 ms 49788 KB Output is correct
2 Correct 2093 ms 52864 KB Output is correct
3 Correct 2253 ms 49920 KB Output is correct