# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
242622 | kshitij_sodani | 학교 설립 (IZhO13_school) | C++17 | 338 ms | 36456 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
//#define endl '\n'
llo n,m,s;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m>>s;
vector<pair<llo,llo>> kk;
for(llo i=0;i<n;i++){
llo aa,bb;
cin>>aa>>bb;
kk.pb({aa,bb});
}
sort(kk.begin(),kk.end());
llo su=0;
reverse(kk.begin(),kk.end());
set<pair<llo,llo>> ss;
set<pair<llo,llo>> tt;
set<pair<llo,llo>> mm;
for(llo i=0;i<n;i++){
if(i<m){
su+=kk[i].a;
ss.insert({kk[i].a-kk[i].b,i});
}
else{
tt.insert({-kk[i].b,i});
mm.insert({-kk[i].a,i});
}
}
if(m==n){
cout<<su<<endl;
return 0;
}
for(llo i=0;i<s;i++){
llo x=-(*tt.begin()).a;
llo y=-(*ss.begin()).a-(*mm.begin()).a;
if(y>x){
su+=y;
ss.erase(ss.begin());
pair<llo,llo> no=*(mm.begin());
mm.erase(mm.begin());
mm.insert({kk[no.b].a-kk[no.b].b,no.b});
}
else{
pair<llo,llo> no=*(tt.begin());
tt.erase(tt.begin());
su+=-no.a;
}
}
cout<<su<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |