Submission #712913

# Submission time Handle Problem Language Result Execution time Memory
712913 2023-03-20T12:39:28 Z yuseok0803 Hotel (CEOI11_hot) C++14
100 / 100
1016 ms 53048 KB
#include <stdio.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stack>
#include <ctype.h>
#define p(x,y) pair<x, y>
#define pii pair<int, int>
#define v(x) vector<x>
#define q(x) queue<x>
#define pq(x) priority_queue<x>
#define uppq(x, comp) priority_queue<x, vector<x>, comp>
#define st(x) set<x>  
#define m(x, y) map<x, y>
#define fi(s,e) for(int i=s;i<e;i++)
#define fj(s,e) for(int j=s;j<e;j++)
#define fk(s,e) for(int k=s;k<e;k++)
typedef long long int ll;
typedef unsigned long long int ull;
typedef __int128 ulll;
using namespace std;

int main(void){
	int n,m,o;
	scanf("%d%d%d",&n,&m,&o);
	multiset<pii> hot;
	multiset<pii>::iterator it;
	v(pii) vec;
	v(ll) ans;
	fi(0,n){
		int c,p;
		scanf("%d%d",&c,&p);
		hot.insert({p,c});
	}
	fi(0,m){
		int v,d;
		scanf("%d%d",&v,&d);
		vec.push_back({v,d});
	}
	
	sort(vec.begin(), vec.end());
	int sz = vec.size();
	
	for(int i = sz-1; i >= 0; i--){
		it = hot.lower_bound({vec[i].second, 0});
		if(it!=hot.end() && (*it).second < vec[i].first){
			ans.push_back({vec[i].first-(*it).second});
			hot.erase(it);
		}
	}
	
	sort(ans.begin(), ans.end());
	ll cor_ans=0;
	sz = ans.size();
	for(int i = sz-1; i >= 0; i--){
		if(sz-i > o) break;
		cor_ans+=ans[i];
	}
	printf("%lld\n", cor_ans);
	return 0;
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  scanf("%d%d%d",&n,&m,&o);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
hot.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   scanf("%d%d",&c,&p);
      |   ~~~~~^~~~~~~~~~~~~~
hot.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |   scanf("%d%d",&v,&d);
      |   ~~~~~^~~~~~~~~~~~~~
# 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 0 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 7 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 2888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 4888 KB Output is correct
2 Correct 56 ms 4336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 341 ms 14572 KB Output is correct
2 Correct 138 ms 8280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 601 ms 28844 KB Output is correct
2 Correct 749 ms 37796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 821 ms 34224 KB Output is correct
2 Correct 911 ms 53048 KB Output is correct
3 Correct 1016 ms 50328 KB Output is correct