-
Notifications
You must be signed in to change notification settings - Fork 0
/
C. Oranges and Apples.cpp
79 lines (77 loc) · 1.71 KB
/
C. Oranges and Apples.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma GCC optimize("O2")
#include <fstream>
#include <string>
#include <iostream>
#include <bitset>
#include <math.h>
#include <string>
#include <algorithm>
#include<bits/stdc++.h>
#include <vector>
#include <queue>
#include<stdio.h>
#include<ctype.h>
#define ll long long
using namespace std;
ll t;
ll n;
struct box{
ll a;
ll o;
ll i;
};
bool csort(box one, box two){
return (one.a + one.o) < (two.a + two.o);
}
bool csorta(box one, box two){
return one.a < two.a;
}
bool csorto(box one, box two){
return one.o < two.o;
}
vector<box> boxes;
vector<box> curused;
int main(){
cin >> t;
for (int z = 0; z < t; z++){
cin >> n;
boxes.clear();
curused.clear();
ll a, b;
ll ta = 0;
ll tb = 0;
ll ca = 0;
ll cb = 0;
for (int x = 0; x < 2*n - 1; x++){
cin >> a >> b;
ta += a;
tb += b;
boxes.push_back({a, b, x + 1});
}
ta = (ta + 1)/2;
tb = (tb + 1)/2;
sort(boxes.begin(), boxes.end(), csorta);
bool even = false;
for (int x = 2*n - 2; x >= 0; x-=2){
cb += boxes[x].o;
}
if (cb >= tb){
even = true;
}
if (even){
cout << "YES\n";
for (int x = 2*n - 2; x >= 0; x-=2){
cout << boxes[x].i << " ";
}
cout << "\n";
}
else{
cout << "YES\n";
for (int x = 2*n - 3; x >= 0; x-=2){
cout << boxes[x].i << " ";
}
cout << boxes[2*n - 2].i << " ";
cout << "\n";
}
}
}