Submission #727498

# Submission time Handle Problem Language Result Execution time Memory
727498 2023-04-20T21:18:38 Z beaconmc Hotel (CEOI11_hot) C++14
20 / 100
1482 ms 60180 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;

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());



  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

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 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 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 1420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 5432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 164 ms 10448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 537 ms 26024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1401 ms 51296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1482 ms 60180 KB Output isn't correct
2 Halted 0 ms 0 KB -