제출 #89096

#제출 시각아이디문제언어결과실행 시간메모리
89096lazarus88학교 설립 (IZhO13_school)C++14
5 / 100
2033 ms24852 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n,m,s,cnt=0; set <pair<int,int > > st1; set< pair< int,pair <int ,int> > > st; cin>>n>>m>>s; int a[100001],b[100001]; for(int i=1;i<=n;i++){ cin>>a[i]>>b[i]; st.insert({-a[i],{-b[i],i}}); st1.insert({-b[i],i}); } while(m>0){ pair<int,pair<int,int> > k=*st.begin(); st.erase(st.begin()); pair<int,pair<int,int> > t=*st.begin(); if(-k.first+b[t.second.second]>-t.first+b[k.second.second]){ cnt+=(-k.first); st1.erase({-b[k.second.second],k.second.second}); } else{ st.erase(st.begin()); st.insert(k); cnt+=(-t.first); st1.erase({-b[t.second.second],t.second.second}); } m--; } while(s>0){ pair<int,int > k=*st1.begin(); st1.erase(st1.begin()); cnt+=(-k.first); s--; } cout<<cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...