Submission #1079611

# Submission time Handle Problem Language Result Execution time Memory
1079611 2024-08-28T18:45:03 Z raspy Hotel (CEOI11_hot) C++17
100 / 100
688 ms 62912 KB
#include <bits/stdc++.h>

#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define ii pair<int, int>
#define f first
#define s second
#define str string
#define pb push_back
#define fun function
#define P 31
#define mod 1'000'000'007
#define inf 1'000'000'000'000'000'000
#define all(x) (x).begin(), (x).end()
#define oopt cout.tie(0);ios_base::sync_with_stdio(false);

using namespace std;

void solve()
{
	int n, m, o;
	cin >> n >> m >> o;
	multiset<ii> sb;
	for (int i = 0; i < n; i++)
	{
		int cn, kp;
		cin >> cn >> kp;
		sb.insert({kp, cn});
	}
	vector<ii> pn(m);
	for (ii&v:pn)
		cin >> v.f >> v.s;
	sort(all(pn));
	reverse(all(pn));
	vi rz;
	for (int i = 0; i < m; i++)
	{
		if (sb.empty()) break;
		auto it = sb.lower_bound({pn[i].s, 0});
		if (it == sb.end()) continue;
		if (it->f < pn[i].s) it++;
		rz.pb(pn[i].f-it->s);
		sb.erase(it);
	}
	sort(all(rz));
	reverse(all(rz));
	int rez = 0;
	for (int i = 0; i < min((int)rz.size(), o); i++)
		rez += max(rz[i], 0ll);
	cout << rez << "\n";
}

signed main()
{
	oopt;
	solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 5600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 9708 KB Output is correct
2 Correct 44 ms 7636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 209 ms 25800 KB Output is correct
2 Correct 105 ms 14144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 481 ms 50624 KB Output is correct
2 Correct 548 ms 51392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 564 ms 59332 KB Output is correct
2 Correct 593 ms 62912 KB Output is correct
3 Correct 688 ms 60060 KB Output is correct