Submission #727511

# Submission time Handle Problem Language Result Execution time Memory
727511 2023-04-20T22:11:40 Z beaconmc Hotel (CEOI11_hot) C++14
100 / 100
2011 ms 101832 KB

#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

//{capacity, cost}
vector<vector<ll>> stuff;
vector<ll> profit;
multiset<vector<ll>> idk;

int main(){
  ll n,m,o;
  cin >> n >> m >> o;
  FOR(i,0,n){
    ll a,b;
    cin >> a >> b;
    idk.insert({b,a});
  }
  FOR(i,0,m){
    ll a,b;
    cin >> a >> b;
    stuff.push_back({a,b});
  }

  sort(stuff.begin(), stuff.end());
  reverse(stuff.begin(), stuff.end());
  vector<ll> profits;

  for (auto&i : stuff){
    if (idk.size()){
      auto it = idk.upper_bound({i[1], 0});
      if (it == idk.end()) continue;

      ll sus = (*idk.upper_bound({i[1], 0}))[1];
      profits.push_back(i[0] - sus);

      idk.erase(idk.upper_bound({i[1], 0}));
    }
  }
  sort(profits.begin(), profits.end());
  reverse(profits.begin(), profits.end());
  ll ans = 0;
  FOR(i,0,min((ll)o, (ll) profits.size())){
    ans += max((ll) 0, (ll) profits[i]);
  }
  cout << ans;






}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 111 ms 6972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 214 ms 12276 KB Output is correct
2 Correct 154 ms 11532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 749 ms 33600 KB Output is correct
2 Correct 372 ms 25584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1515 ms 67052 KB Output is correct
2 Correct 1952 ms 82396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1835 ms 82232 KB Output is correct
2 Correct 1956 ms 101832 KB Output is correct
3 Correct 2011 ms 98996 KB Output is correct