Submission #743278

# Submission time Handle Problem Language Result Execution time Memory
743278 2023-05-17T09:22:53 Z Dan4Life Hotel (CEOI11_hot) C++17
100 / 100
1870 ms 39540 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];
	multiset<int,greater<>> S; 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])
			S.insert(a[i][0]-itr->second), Ms.erase(itr);
	}
	while(k-- and size(S)) ans+=max(0ll,*begin(S)), S.erase(begin(S));
	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 1 ms 212 KB Output is correct
2 Correct 1 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 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 84 ms 3476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 157 ms 5784 KB Output is correct
2 Correct 104 ms 5324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 509 ms 16124 KB Output is correct
2 Correct 242 ms 9664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1172 ms 31712 KB Output is correct
2 Correct 1176 ms 31692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1393 ms 39540 KB Output is correct
2 Correct 1573 ms 39504 KB Output is correct
3 Correct 1870 ms 39504 KB Output is correct