Submission #875416

# Submission time Handle Problem Language Result Execution time Memory
875416 2023-11-19T15:35:36 Z lalig777 Hotel (CEOI11_hot) C++14
30 / 100
821 ms 29396 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int main(){
	int n, m, o;
	priority_queue<int>pq;
	cin>>n>>m>>o;
	vector<pair<int,int> >habitacions(n);
	vector<int>max_prof(n, 0);
	vector<pair<int,int> >offers(m);
	for (int i=0; i<n; i++) cin>>habitacions[i].first>>habitacions[i].second;
	sort(habitacions.begin(), habitacions.end());
	for (int i=0; i<m; i++) cin>>offers[i].second>>offers[i].first;
	sort(offers.begin(), offers.end());
	int k=0;
	for (int i=0; i<n; i++){
		int max_people=habitacions[i].second;
		for (int j=k; j<m; j++){
			if (offers[j].first<=max_people) pq.push(offers[j].second);
			else{
				k=j;
				break;
			}if (j==m-1) k=m;
		}if (!pq.empty()){
			max_prof[i]=pq.top()-habitacions[i].first;
			pq.pop();
		}
	}sort(max_prof.begin(), max_prof.end());
	long long int ans=0;
	for (int i=n-1; i>=n-o; i--) ans+=max_prof[i];
	cout<<ans<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 2752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 97 ms 4340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 291 ms 12008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 662 ms 23856 KB Output is correct
2 Incorrect 555 ms 23632 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 637 ms 26716 KB Output is correct
2 Incorrect 821 ms 29396 KB Output isn't correct
3 Halted 0 ms 0 KB -