Submission #933188

# Submission time Handle Problem Language Result Execution time Memory
933188 2024-02-25T08:47:34 Z Cookie Hotel (CEOI11_hot) C++14
100 / 100
860 ms 64696 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define sz(a) (int)a.size()
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mpp make_pair
const ld PI = 3.14159265359, prec = 1e-9;;
using u128 = __uint128_t;
//const int x[4] = {1, 0, -1, 0};
//const int y[4] = {0, -1, 0, 1};
const ll mod =1e9 + 7;
const int mxn = 5e5 + 5, mxq = 1e5 + 5, sq = 300, mxv = 1e4 + 5;
//const int base = (1 <<18);
const ll inf = 3e9 + 5, neg = -69420, inf2 = 1e14;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// have fun!
// <3;
int n, m, o;
pll offer[mxn + 1];
void solve(){
    cin >> n >> m >> o;
    multiset<pair<ll, ll>>room;
    for(int i = 1; i <= n; i++){
        int c, p; cin >> c >> p; room.insert(mpp(p, c));
    }
    for(int i = 1; i <= m; i++){
        cin >> offer[i].fi >> offer[i].se;
    }
    sort(offer + 1, offer + m + 1, greater<pll>());
    vt<ll>cand;
    for(int i = 1; i <= m; i++){
        auto it = room.lower_bound(mpp(offer[i].se, -1));
        if(it == room.end())continue;
        cand.pb(offer[i].fi - (*it).se); room.erase(it);
    }
    sort(ALLR(cand));
    ll ans = 0;
    for(int i = 0; i < min(sz(cand), o); i++){
        ans += max((ll)0, cand[i]);
    }
    cout << ans;

}


signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("SODOCLA.INP", "r", stdin);
    //freopen("SODOCLA.INP", "w", stdout);
    int tt; tt = 1;
    while(tt--){
        solve();

    }
    return(0);
}
/*
10 5
2 3 4 5 6
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 5600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 8028 KB Output is correct
2 Correct 46 ms 9180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 195 ms 19396 KB Output is correct
2 Correct 95 ms 15276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 560 ms 36624 KB Output is correct
2 Correct 652 ms 53596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 658 ms 45336 KB Output is correct
2 Correct 670 ms 64696 KB Output is correct
3 Correct 860 ms 60944 KB Output is correct