Submission #743280

# Submission time Handle Problem Language Result Execution time Memory
743280 2023-05-17T09:24:04 Z Dan4Life Hotel (CEOI11_hot) C++17
100 / 100
1656 ms 43748 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mxN = (int)5e5+10;
int n, m, k, x, y;
array<int,2> a[mxN];

int32_t main(){
	cin >> n >> m >> k; multiset<pair<int,int>> Ms; 
	while(n--) cin >> x >> y, Ms.insert({y,x});
	for(int i = 0; i < m; i++) cin >> a[i][0] >> a[i][1];
	priority_queue<int> Q; int ans = 0; sort(a,a+m);
	for(int i = m-1; i >= 0; i--){
		auto itr=Ms.lower_bound({a[i][1],0});
		if(itr!=end(Ms) and itr->second < a[i][0])
			Q.push(a[i][0]-itr->second), Ms.erase(itr);
	}
	while(k-- and size(Q)) ans+=max(0ll,Q.top()), Q.pop();
	cout << ans;
}
# 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 Correct 0 ms 212 KB Output is correct
# 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 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 3816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 157 ms 6468 KB Output is correct
2 Correct 103 ms 5580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 482 ms 18048 KB Output is correct
2 Correct 224 ms 10772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1029 ms 35876 KB Output is correct
2 Correct 1246 ms 31656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1456 ms 43680 KB Output is correct
2 Correct 1341 ms 43748 KB Output is correct
3 Correct 1656 ms 43692 KB Output is correct