Submission #727497

#TimeUsernameProblemLanguageResultExecution timeMemory
727497beaconmcHotel (CEOI11_hot)C++14
0 / 100
3066 ms83372 KiB


#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;

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

  sort(stuff.begin(), stuff.end());
  ll cur = 0;
  FOR(i,0,stuff.size()){
    if (i!=0 && stuff[i][2] != stuff[i-1][2]){
      cur++;
    }
    stuff[i][0] = cur;
  }

  sort(stuff.begin(), stuff.end());
  reverse(stuff.begin(), stuff.end());

  for (auto&i : stuff){
    cout << i[0] << " " << i[1] << " " << i[2]<< endl;
  }
  cout << endl;

  multiset<ll> idk;
  for (auto&i : stuff){

    if (i[1] == 0 && idk.size() > 0){

      profit.push_back(i[2]-(*idk.begin()));

      idk.erase(*idk.begin());
    }else if (i[1] == 1){
      idk.insert(i[2]);

    }
  }
  sort(profit.begin(), profit.end());
  reverse(profit.begin(), profit.end());
  ll ans = 0;

  FOR(i,0,min((ll) o, (ll) profit.size())){
    ans += max(profit[i],(ll) 0);
  }
  cout << ans;






}

Compilation message (stderr)

hot.cpp: In function 'int main()':
hot.cpp:8:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   32 |   FOR(i,0,stuff.size()){
      |       ~~~~~~~~~~~~~~~~             
hot.cpp:32:3: note: in expansion of macro 'FOR'
   32 |   FOR(i,0,stuff.size()){
      |   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...