Submission #597184

# Submission time Handle Problem Language Result Execution time Memory
597184 2022-07-15T16:54:48 Z Trisanu_Das Hotel (CEOI11_hot) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long int
 
signed main(){
  int n, m, o; cin >> n >> m >> o;
  multiset<pair<int, int> > rooms;
  for(int i = 0; i < n; i++){
    int c, p; cin >> c >> p; rooms.insert({c, p});
  }
  pair<int, int> requests[m];
  for(int i = 0; i < m; i++) cin >> requests[i].first >> requests[i].second;
 sort(requests.begin(), requests.end(), [] (pair<int, int> i, pair<int, int> j)
	{
		return i.second > j.second;
	});
  
  int ans = 0;
  vector<int> choosed;
  
  for(pair<int, int> p : requests){
    int req = p.first, price = p.second;
    auto choice = rooms.lower_bound({req, -1});
    if(choice == rooms.end()) continue;
    if(price > choice.second) choosed.push_back(price - choice.second);
  }
  sort(choosed.begin(), choosed.end(), greater<int>());
  for(int i = 0; i < o; i++) ans += choosed[i];
  cout << ans << '\n';
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:13:16: error: request for member 'begin' in 'requests', which is of non-class type 'std::pair<long long int, long long int> [m]'
   13 |  sort(requests.begin(), requests.end(), [] (pair<int, int> i, pair<int, int> j)
      |                ^~~~~
hot.cpp:13:34: error: request for member 'end' in 'requests', which is of non-class type 'std::pair<long long int, long long int> [m]'
   13 |  sort(requests.begin(), requests.end(), [] (pair<int, int> i, pair<int, int> j)
      |                                  ^~~
hot.cpp:25:23: error: 'struct std::_Rb_tree_const_iterator<std::pair<long long int, long long int> >' has no member named 'second'
   25 |     if(price > choice.second) choosed.push_back(price - choice.second);
      |                       ^~~~~~
hot.cpp:25:64: error: 'struct std::_Rb_tree_const_iterator<std::pair<long long int, long long int> >' has no member named 'second'
   25 |     if(price > choice.second) choosed.push_back(price - choice.second);
      |                                                                ^~~~~~