This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |