# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
933120 | imarn | 학교 설립 (IZhO13_school) | C++14 | 2060 ms | 21424 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |