Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Task :
- Author : Phumipat C. [MAGCARI]
- Language: C++
- Created : 03 May 2023 [18:53]
- */
- #include<bits/stdc++.h>
- using namespace std;
- void solve(){
- int n,ans = 0;
- cin >> n;
- priority_queue<int > heap;
- for(int i=1;i<=n;i++){
- int y,k;
- cin >> y >> k;
- ans+=y;
- heap.push(-(k-y));
- }
- for(int i=1;i<=n/2;i++){
- ans-=heap.top();
- heap.pop();
- }
- cout << ans << '\n';
- }
- int main(){
- int q;
- cin >> q;
- while(q--){
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment