Submission #739944

# Submission time Handle Problem Language Result Execution time Memory
739944 2023-05-11T17:27:53 Z Unforgettablepl Hotel (CEOI11_hot) C++17
100 / 100
1010 ms 62912 KB
/*
ID: samikgo1
TASK:
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
//#define f first
//#define s second
//#define x first
//#define y second
const int INF = INT32_MAX;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("measurement.in","r",stdin);
//    freopen("measurement.out","w",stdout);
    ll n,m,o;
    cin >> n >> m >> o;
    vector<pll> offers(m);
    multiset<pll> roomss;
    for (int i = 0; i < n; i++) {
        ll a,b;
        cin >> a >> b;
        roomss.emplace(b,a);
    }
    for(pll&i:offers)cin>>i.first>>i.second;
    sort(allr(offers));
    vector<ll> ans;
    for (pll &i: offers) {
        // i.first is rate
        // i.second is requirement
        auto room = roomss.lower_bound({i.second,(ll)0});
        if(room==roomss.end()){ continue;}
        ll a = i.first-room->second;
        roomss.erase(room);
        if(a>0) {ans.emplace_back(a);};
    }
    sort(allr(ans));
    ll anss = 0;
    for (ll i = 0; i < min(o,(ll)ans.size()); i++) {
        anss += ans[i];
    }
    cout << anss;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 3840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 6432 KB Output is correct
2 Correct 65 ms 7368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 284 ms 18184 KB Output is correct
2 Correct 126 ms 13916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 606 ms 35828 KB Output is correct
2 Correct 700 ms 47124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 693 ms 43632 KB Output is correct
2 Correct 783 ms 62912 KB Output is correct
3 Correct 1010 ms 59964 KB Output is correct