답안 #530574

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
530574 2022-02-25T21:07:05 Z FelipeH Hotel (CEOI11_hot) C++14
20 / 100
2837 ms 8668 KB
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;

vector<int> roomSize, roomCost;
vector<pii> offer;

int main(){
  int n, m, o; cin >> n >> m >> o;
  for(int i = 0;i<n;i++){
    int a, b; cin >> a >> b;
    roomCost.push_back(a); roomSize.push_back(b);
  }
  sort(roomCost.begin(),roomCost.end());
  sort(roomSize.begin(),roomSize.end());
  for(int i = 0;i<m;i++){
    int a, b; cin >> a >> b;
    offer.push_back(make_pair(a,b));
  }
  sort(offer.begin(),offer.end());
  long long int resp = 0;
  int cnt = 0;
  for(int i = offer.size() - 1; i >= 0 && cnt < o; i--){
    if(roomCost.empty()) break;
    // printf("processing offer (%d,%d)\n",offer[i].first, offer[i].second);
    auto it = lower_bound(roomSize.begin(), roomSize.end(), offer[i].second);
    if(it == roomSize.end()) continue;
    int roomId = it - roomSize.begin();
    if(offer[i].first - roomCost[roomId] > 0){
      // printf("-chose room %d (%d,%d) with %d profit\n",roomId, roomCost[roomId], roomSize[roomId], offer[i].first - roomCost[roomId]);
      resp += offer[i].first - roomCost[roomId];
      roomCost.erase(roomCost.begin() + roomId); roomSize.erase(roomSize.begin() + roomId);
      cnt++;
    }
  }
  cout << resp << "\n";
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 113 ms 1236 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 395 ms 1976 KB Output is correct
2 Incorrect 154 ms 1544 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2837 ms 4064 KB Output is correct
2 Incorrect 302 ms 3208 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2572 ms 7644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1008 ms 8668 KB Output isn't correct
2 Halted 0 ms 0 KB -