답안 #546323

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546323 2022-04-07T09:14:03 Z blue Hotel (CEOI11_hot) C++17
20 / 100
620 ms 55596 KB
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
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';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Incorrect 0 ms 320 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 4940 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 8476 KB Output is correct
2 Incorrect 61 ms 6948 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 240 ms 23628 KB Output is correct
2 Incorrect 105 ms 12768 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 489 ms 46908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 620 ms 55596 KB Output isn't correct
2 Halted 0 ms 0 KB -