제출 #530712

#제출 시각아이디문제언어결과실행 시간메모리
530712peuchHotel (CEOI11_hot)C++17
컴파일 에러
0 ms0 KiB
#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; multiset<long long> moedas; for(int i = offer.size() - 1; i >= 0; 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]; moedas.insert(offer[i].first - roomCost[roomId]); if(moedas.size() > o){ resp -= *moedas.begin(); moedas.erase(moedas.begin()); } roomCost.erase(roomCost.begin() + roomId); roomSize.erase(roomSize.begin() + roomId); cnt++; } } cout << resp << "\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

hot.cpp: In function 'int main()':
hot.cpp:35:24: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |       if(moedas.size() > o){
      |          ~~~~~~~~~~~~~~^~~
hot.cpp:40:7: error: 'cnt' was not declared in this scope; did you mean 'int'?
   40 |       cnt++;
      |       ^~~
      |       int