forked from sitz/UVa-Online-Judge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path10026.cpp
52 lines (47 loc) · 859 Bytes
/
10026.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
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int(i) = int(a); (i) < int(b); (i)++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define mp make_pair
inline bool by_key_desc_val_asc(const pair<double, int> &a, const pair<double, int> &b)
{
if (a.first == b.first)
{
return a.second < b.second;
}
return a.first > b.first;
}
static int cases, n, t, f;
static vector<pair<double, int>> v;
int main()
{
scanf("%d", &cases);
while (cases--)
{
scanf("%d", &n);
v.clear();
FOR(i, 0, n)
{
scanf("%d%d", &t, &f);
v.pb(mp(f * 1.0 / t, i + 1));
}
sort(ALL(v), by_key_desc_val_asc);
int sz = SZ(v);
FOR(i, 0, sz)
{
if (i > 0)
{
printf(" ");
}
printf("%d", v[i].second);
}
printf("\n");
if (cases)
{
printf("\n");
}
}
return 0;
}