Submission #259416

# Submission time Handle Problem Language Result Execution time Memory
259416 2020-08-07T18:50:29 Z islingr Hotel (CEOI11_hot) C++17
100 / 100
1262 ms 49504 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define rall(x) (x).rbegin(), (x).rend()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, m, o; cin >> n >> m >> o;
	multiset<pair<int, int>> room;
	rep(i, 0, n) {
		int p, c; cin >> c >> p;
		room.insert({p, c});
	}

	vector<pair<int, int>> offer(m);
	rep(i, 0, m) {
		int v, d; cin >> v >> d;
		offer[i] = {v, d};
	}

	sort(rall(offer));
	vector<int> res;
	for (auto [v, d] : offer) {
		auto it = room.lower_bound({d, 0});
		if (it == end(room)) continue;
		res.push_back(v - it->second);
		room.erase(it);
	}
	
	sort(rall(res)); int64_t ans = 0;
	rep(i, 0, min(o, int(res.size()))) {
		if (res[i] <= 0) break;
		ans += res[i];
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 4472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 7544 KB Output is correct
2 Correct 71 ms 6136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 324 ms 20212 KB Output is correct
2 Correct 154 ms 10356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 771 ms 39812 KB Output is correct
2 Correct 896 ms 40004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 942 ms 46240 KB Output is correct
2 Correct 999 ms 49504 KB Output is correct
3 Correct 1262 ms 46444 KB Output is correct