Submission #597576

# Submission time Handle Problem Language Result Execution time Memory
597576 2022-07-16T10:43:07 Z hail Hotel (CEOI11_hot) C++17
20 / 100
4000 ms 19812 KB
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

bool or_sor(pair<ll, ll> a, pair<ll, ll> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first>b.first;
}

void solve()
{
    ll n, m, o;
    cin>>n>>m>>o;

    vector<pair<ll, ll>> rooms(n);
    // cap upkeep

    vector<pair<ll,ll>> orders(m);
    // rent mincap

    for(int i=0; i<n; i++)
    {
        cin>>rooms[i].second>>rooms[i].first;
    }
    for(int i=0; i<m; i++)
    {
        cin>>orders[i].first>>orders[i].second;
    }

    sort(rooms.begin(), rooms.end());
    sort(orders.begin(), orders.end(), or_sor);

    vector<ll> max_prof(min(n, m));

    pair<ll, ll> ord;
    auto it=rooms.begin();

    for(ll i=0; i<min(m, n); i++)
    {
        ord=orders[i];
        it = lower_bound(rooms.begin(), rooms.end(), make_pair(ord.second, (ll) 0));
        max_prof[i]=ord.first-(*it).second;
        rooms.erase(it);
    }

    sort(max_prof.rbegin(), max_prof.rend());

    ll ans{};

    for(int i=0; i<o; i++)
    {
        if(max_prof[i]<=0) break;
        ans+=max_prof[i];
    }

    cout<<ans;

}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t=1;
    while(t--)
    {
        solve();
    }

    
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 333 ms 1888 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 868 ms 3060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4074 ms 8112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4058 ms 15908 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4040 ms 19812 KB Time limit exceeded
2 Halted 0 ms 0 KB -