# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167900 | GioChkhaidze | Schools (IZhO13_school) | C++14 | 421 ms | 32456 KiB |
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 <bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;
const int N=3e5+5;
ll n,m,s,a[N],b[N],f[N],ans;
vector < pair < ll , pair < ll , ll > > > v;
main () {
cin>>n>>m>>s;
for (int i=1; i<=n; i++) {
cin>>a[i]>>b[i];
v.push_back({a[i],{i,0}});
v.push_back({b[i],{i,1}});
}
sort(v.begin(),v.end());
reverse(v.begin(),v.end());
for (int i=0; i<v.size(); i++) {
ll type=v[i].S.S,idx=v[i].S.F;
if (f[idx]) continue;
if (!type) {
if (m) {
ans+=a[idx];
m--;
f[idx]=1;
}
}
else {
if (s) {
ans+=b[idx];
s--;
f[idx]=1;
}
}
}
cout<<ans<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |