Submission #385249

# Submission time Handle Problem Language Result Execution time Memory
385249 2021-04-03T19:35:07 Z ritul_kr_singh Hotel (CEOI11_hot) C++17
100 / 100
1286 ms 43868 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' <<
#define nl << '\n'

signed main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, m, o; cin >> n >> m >> o;
	array<int, 2> offers[m];
	array<int, 3> room;
	set<array<int, 3>> rooms;
	for(int i=0; i<n; ++i){
		cin >> room[1] >> room[0];
		room[2] = i;
		rooms.insert(room);
	}
	for(auto &i : offers) cin >> i[0] >> i[1];
	sort(offers, offers+m, greater<>());
	vector<int> pos;

	for(auto &i : offers){
		auto f = rooms.lower_bound({i[1], 0});
		if(f != rooms.end()){
			pos.push_back(i[0] - (*f)[1]);
			rooms.erase(f);
		}
	}

	sort(pos.begin(), pos.end(), greater<>());
	int ans = 0;
	for(int i=0; i<min(o, (int)pos.size()); ++i){
		if(pos[i]>0) ans += pos[i];
	}
	cout << ans;


}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 4080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 109 ms 7016 KB Output is correct
2 Correct 80 ms 5996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 338 ms 18400 KB Output is correct
2 Correct 180 ms 10852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 800 ms 36072 KB Output is correct
2 Correct 1041 ms 35932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 990 ms 43732 KB Output is correct
2 Correct 1073 ms 43868 KB Output is correct
3 Correct 1286 ms 43868 KB Output is correct