Submission #512865

# Submission time Handle Problem Language Result Execution time Memory
512865 2022-01-16T19:07:24 Z blue Hotel (CEOI11_hot) C++17
10 / 100
418 ms 35396 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

using ll = long long;
#define sz(x) int(x.size())

struct obj
{
    int s;
    int v;
    int t;
};

bool operator < (obj A, obj B)
{
    if(A.s != B.s) return A.s > B.s;
    else return A.t > B.t;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m, o;
    cin >> n >> m >> o;

    vector<obj> a(m+n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i].v >> a[i].s;
        a[i].t = 1; //room
    }

    for(int j = n; j < n+m; j++)
    {
        cin >> a[j].v >> a[j].s;
        a[j].t = 0; //customer
    }

    sort(a.begin(), a.end());

    ll rooms_total = 0;
    // int room_count = 0;

    multiset<int> actual, fake;

    for(obj x: a)
    {
        // cerr << "obj = " << x.v << ' ' << x.t << '\n';
        if(x.t == 1)
        {
            rooms_total += x.v;
            fake.insert(x.v);
        }
        else if(x.t == 0)
        {
            if(sz(actual) == o)
            {
                actual.insert(x.v);
                actual.erase(*actual.begin());
            }
            else
            {
                actual.insert(x.v);
                if(fake.empty() || *actual.begin() < *fake.begin())
                    actual.erase(actual.begin());
                else
                    fake.erase(fake.begin());
            }
        }
    }

    ll ans = -rooms_total;
    for(int a: actual) ans += a;
    for(int f: fake) ans += f;

    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 972 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 3036 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 5168 KB Output is correct
2 Incorrect 51 ms 4808 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 215 ms 14360 KB Output is correct
2 Incorrect 108 ms 8364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 400 ms 28392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 418 ms 35396 KB Output isn't correct
2 Halted 0 ms 0 KB -