Submission #167015

#TimeUsernameProblemLanguageResultExecution timeMemory
167015itglSchools (IZhO13_school)C++14
20 / 100
414 ms9456 KiB
#include<bits/stdc++.h> #define pb push_back #define ff first #define ss second #define mp make_pair using namespace std; priority_queue<pair<int,pair<int,int> > > pq,pq1; int main(){ int n,m,s; cin >> n >> m >> s; for(int i=1;i<=n;i++){ int x,y; cin >> x >> y; pq.push(mp(x-y,mp(x,y))); } int res=0; //cout << "==================\n"; while(m--){ //cout << pq.top().ss.ff << ' ' << pq.top().ss.ss << '\n'; res+=pq.top().ss.ff; pq.pop(); } //cout<<"====================\n"; int k=pq.size(); while(k--){ pq1.push(mp(-pq.top().ff,mp(pq.top().ss.ff,pq.top().ss.ss))); pq.pop(); } while(s--){ //cout << pq1.top().ss.ff << ' ' << pq1.top().ss.ss << '\n'; res+=pq1.top().ss.ss; pq1.pop(); } cout <<res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...