Submission #210481

#TimeUsernameProblemLanguageResultExecution timeMemory
210481LorenaMariaHotel (CEOI11_hot)C++14
100 / 100
2101 ms46240 KiB
#include <iostream> #include <algorithm> #include <set> #include <vector> using namespace std; int n,m,k; long long r; pair <int,int> o[500001]; multiset < pair <int,int> > s; vector <int> v; int main() { cin>>n>>m>>k; for(int i=1;i<=n;i++) { int c,p; cin>>c>>p; s.insert(make_pair(p,c)); } for(int i=1;i<=m;i++) cin>>o[i].first>>o[i].second; sort(o+1,o+m+1); for(int i=m;i>0;i--) { set < pair <int,int > > :: iterator it=s.lower_bound(make_pair(o[i].second,0)); if(it==s.end()) continue; if(o[i].first>(*it).second) { v.push_back(o[i].first-(*it).second); s.erase(it); } } sort(v.rbegin(),v.rend()); if(k>v.size()) k=v.size(); for(int i=0;i<k;i++) r+=1LL*v[i]; cout<<r<<'\n'; return 0; }

Compilation message (stderr)

hot.cpp: In function 'int main()':
hot.cpp:31:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(k>v.size())
      ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...