Submission #933120

#TimeUsernameProblemLanguageResultExecution timeMemory
933120imarnSchools (IZhO13_school)C++14
15 / 100
2060 ms21424 KiB
#include<bits/stdc++.h>
//#include "game.h"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define vp vector<pii>
using namespace std;
const int N=3e5+5;
ll a[N],b[N],vis[N]{0};
priority_queue<pair<ll,int>>aa,bb;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,m,s;cin>>n>>m>>s;
    for(int i=0;i<n;i++)cin>>a[i]>>b[i],aa.push({a[i],i}),bb.push({b[i],i});
    int x=m;ll tt=0;while(x--)tt+=aa.top().f,vis[aa.top().s]=1,aa.pop();x=s;
    while(x--){
        if(!vis[bb.top().s])tt+=bb.top().f,vis[bb.top().s]=1,bb.pop();
        else{
            if(bb.top().f+aa.top().f>a[bb.top().s])tt+=bb.top().f+aa.top().f-a[bb.top().s],vis[aa.top().s]=1,vis[bb.top().s]=1,bb.pop(),aa.pop();
            else x++;
        }
    }cout<<tt;
}
#Verdict Execution timeMemoryGrader output
Fetching results...