답안 #727486

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727486 2023-04-20T21:04:13 Z beaconmc Hotel (CEOI11_hot) C++14
0 / 100
1418 ms 78352 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,a});
  }
  FOR(i,0,m){
    ll a,b;
    cin >> a >> b;
    stuff.push_back({b,-a});
  }

  sort(stuff.begin(), stuff.end());
  ll cur = 0;
  FOR(i,0,stuff.size()){
    if (i!=0 && stuff[i][1] * stuff[i-1][1] < 0){
      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[1]-(*idk.begin()));

      idk.erase(*idk.begin());
    }else{
      idk.insert(i[1]);
    }
  }
  sort(profit.begin(), profit.end());
  reverse(profit.begin(), profit.end());
  ll ans = 0;
  FOR(i,0,min((ll) o, (ll) profit.size())){
    ans += profit[i];
  }
  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()){
      |   ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 1604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 93 ms 7052 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 162 ms 13172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 560 ms 33588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1262 ms 66748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1418 ms 78352 KB Output isn't correct
2 Halted 0 ms 0 KB -