답안 #727509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727509 2023-04-20T22:07:13 Z beaconmc Hotel (CEOI11_hot) C++14
30 / 100
1922 ms 79360 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;






}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 142 ms 7784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 261 ms 12972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 886 ms 34292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1788 ms 68156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1922 ms 79360 KB Output isn't correct
2 Halted 0 ms 0 KB -