Submission #546325

# Submission time Handle Problem Language Result Execution time Memory
546325 2022-04-07T09:16:41 Z blue Hotel (CEOI11_hot) C++17
20 / 100
599 ms 39384 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)
	{
		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';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 3432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 78 ms 5732 KB Output is correct
2 Incorrect 53 ms 5324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 259 ms 15896 KB Output is correct
2 Incorrect 105 ms 9664 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 451 ms 31548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 599 ms 39384 KB Output isn't correct
2 Halted 0 ms 0 KB -