-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC.cpp
46 lines (45 loc) · 959 Bytes
/
C.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
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline int len(const T &a) { return a.size(); }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tc;
cin >> tc;
while (tc--) {
int n;
cin >> n;
n = 2 * n - 1;
vector<tuple<int, int, int>> a(n);
for (int i = 0; i < n; ++i) {
cin >> get<0>(a[i]) >> get<1>(a[i]);
get<2>(a[i]) = i;
}
sort(a.rbegin(), a.rend());
long long sum_odd = 0, sum_even = 0;
for (int i = 0; i < n; ++i) {
if (i & 1) {
sum_odd += get<1>(a[i]);
} else {
sum_even += get<1>(a[i]);
}
}
cout << "YES\n";
if (sum_even >= sum_odd) {
for (int i = 0; i < n; ++i) {
if (!(i & 1)) {
cout << get<2>(a[i]) + 1 << ' ';
}
}
} else {
for (int i = 0; i < n; ++i) {
if (i & 1) {
cout << get<2>(a[i]) + 1 << ' ';
}
}
cout << get<2>(a[0]) + 1;
}
cout << '\n';
}
return 0;
}