# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167015 | itgl | Schools (IZhO13_school) | C++14 | 414 ms | 9456 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |