forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.cpp
More file actions
59 lines (51 loc) · 1.04 KB
/
C.cpp
File metadata and controls
59 lines (51 loc) · 1.04 KB
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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
typedef long long LL;
class box {
public:
int a, o, idx;
bool operator<(const box &r) const {
return a < r.a;
}
};
void run() {
int n;
cin >> n;
int m = (n << 1) - 1;
vector<box> boxes(m);
LL totalo = 0;
REP(i,m) {
cin >> boxes[i].a >> boxes[i].o;
boxes[i].idx = i + 1;
totalo += boxes[i].o;
}
sort(boxes.begin(), boxes.end());
LL tmp = 0;
REP(i,n) {
tmp += boxes[i << 1].o;
}
cout << "YES" << endl;
if ((tmp << 1) >= totalo) {
REP(i,n) {
if (i) cout << " ";
cout << boxes[i << 1].idx;
}
cout << endl;
} else {
REP(i,n-1) {
if (i) cout << " ";
cout << boxes[(i << 1) + 1].idx;
}
cout << " " << boxes[m - 1].idx << endl;
}
}
int main() {
int kase;
for (cin >> kase; kase; --kase) {
run();
}
return 0;
}