Submission #205163

# Submission time Handle Problem Language Result Execution time Memory
205163 2020-02-28T08:33:57 Z ruler Hotel (CEOI11_hot) C++14
100 / 100
1503 ms 48200 KB
// IOI 2021
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 3;

multiset<pii> R;
vector<pii> O;
vector<int> T;

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	
	int n, m, o; cin >> n >> m >> o;
	for (int i = 0; i < n; i++) {
		int c, p; cin >> c >> p;
		R.insert(make_pair(p, c));
	}
	for (int i = 0; i < m; i++) {
		int v, d; cin >> v >> d;
		O.push_back(make_pair(v, d));
	}
	sort(all(O)), reverse(all(O));
	for (pii p : O) {
		auto it = R.lower_bound(make_pair(p.second, 0));
		if (it != R.end()) T.push_back(max(0, p.first - it->second)), R.erase(it);
	}
	sort(all(T)), reverse(all(T));
	ll res = 0;
	for (int i = 0; i < sz(T) && i < o; i++) res += T[i];
	cout << res << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 4468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 96 ms 7664 KB Output is correct
2 Correct 77 ms 6012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 344 ms 20712 KB Output is correct
2 Correct 152 ms 10724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 856 ms 41272 KB Output is correct
2 Correct 1162 ms 41376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1100 ms 47840 KB Output is correct
2 Correct 1346 ms 38832 KB Output is correct
3 Correct 1503 ms 48200 KB Output is correct