Submission #244593

# Submission time Handle Problem Language Result Execution time Memory
244593 2020-07-04T10:30:10 Z TadijaSebez Hotel (CEOI11_hot) C++11
100 / 100
1370 ms 53352 KB
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define pb push_back
int main(){
	multiset<pii> all;
	int n,m,o;scanf("%i %i %i",&n,&m,&o);
	for(int i=1;i<=n;i++){
		int a,b;scanf("%i %i",&a,&b);
		all.insert({b,a});
	}
	vector<pii> qs;
	for(int i=1;i<=m;i++){
		int a,b;scanf("%i %i",&a,&b);
		qs.pb({a,b});
	}
	sort(qs.rbegin(),qs.rend());
	vector<ll> vals;
	for(auto q:qs){
		auto it=all.lower_bound({q.second,0});
		if(it!=all.end()&&it->second<q.first){
			vals.pb(q.first-it->second);
			all.erase(it);
		}
	}
	sort(vals.rbegin(),vals.rend());
	ll ans=0;
	for(int i=0;i<vals.size()&&i<o;i++)ans+=vals[i];
	printf("%lld\n",ans);
	return 0;
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:29:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<vals.size()&&i<o;i++)ans+=vals[i];
              ~^~~~~~~~~~~~
hot.cpp:8:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n,m,o;scanf("%i %i %i",&n,&m,&o);
            ~~~~~^~~~~~~~~~~~~~~~~~~~~
hot.cpp:10:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a,b;scanf("%i %i",&a,&b);
           ~~~~~^~~~~~~~~~~~~~~
hot.cpp:15:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a,b;scanf("%i %i",&a,&b);
           ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 4592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 118 ms 7788 KB Output is correct
2 Correct 83 ms 6132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 372 ms 22148 KB Output is correct
2 Correct 191 ms 11648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 912 ms 43976 KB Output is correct
2 Correct 1010 ms 37852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1044 ms 50252 KB Output is correct
2 Correct 1137 ms 53352 KB Output is correct
3 Correct 1370 ms 50520 KB Output is correct