Submission #1079609

# Submission time Handle Problem Language Result Execution time Memory
1079609 2024-08-28T18:41:57 Z raspy Hotel (CEOI11_hot) C++17
30 / 100
529 ms 35776 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;
	set<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++;
		if (it == sb.end()) continue;
		rz.pb(pn[i].f-it->s);
		sb.erase(it);
		// cout << i << " " << it->f << " " << it->s << "\n";
	}
	sort(all(rz));
	reverse(all(rz));
	int rez = 0;
	for (int i = 0; i < min((int)rz.size(), o); i++)
		if (rz[i] > 0)
			rez += rz[i];
	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 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 4216 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 7076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 204 ms 18136 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 529 ms 35776 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 404 ms 26052 KB Output isn't correct
2 Halted 0 ms 0 KB -