답안 #546322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546322 2022-04-07T09:13:52 Z blue Hotel (CEOI11_hot) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
#include <set>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, m, o;
	cin >> n >> m >> o;

	multiset<pll> rooms; //(capacity, upkeep)

	for(int i = 1; i <= n; i++)
	{
		ll c, p;
		cin >> c >> p;

		rooms.insert({p, c});
	}

	vector<pll> offers(m); //(capacity requirement, gain)
	for(int j = 0; j < m; j++)
	{
		cin >> offers[j].second >> offers[j].first;
	}

	sort(offers.begin(), offers.end(), [] (pll U, pll V)
	{
		if(U.second == V.second) return U.first < V.first;
		else return U.second > V.second;
	});

	ll res = 0;

	int accepted = 0;

	for(pll z : offers)
	{
		if(accepted == o) break;

		ll capreq = z.first;
		ll gain = z.second;

		auto f = rooms.lower_bound({capreq, -1});

		if(f == rooms.end()) continue;

		if(f->second >= gain) continue;

		res += gain - f->second;
		accepted++;

		rooms.erase(f);
	}

	cout << res << '\n';
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:34:2: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   34 |  sort(offers.begin(), offers.end(), [] (pll U, pll V)
      |  ^~~~
      |  qsort