-
Notifications
You must be signed in to change notification settings - Fork 1
/
UVa 10026.cpp
71 lines (49 loc) · 1.04 KB
/
UVa 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <bits/stdc++.h>
using namespace std;
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define iter(i,a,b) for(int i = (a) ; i < (b) ; i++)
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii> iii;
typedef vector <pii> vii;
#define INF 1000000000
#define MAXX 1000
struct job{
int jobID;
int time;
int fine;
};
bool checker(job a1, job a2){
double r1 = (double) a1.fine / a1.time;
double r2 = (double) a2.fine / a2.time;
if(r1 == r2)
return a1.jobID < a2.jobID;
return r1 > r2;
}
int main(){
//READ("UVa 10026.txt");
int tc;
scanf("%d", &tc);
while(tc--){
int n;
scanf("%d", &n);
vector<job> a(n);
rep(i, n){
a[i].jobID = i + 1;
scanf("%d", &a[i].time);
scanf("%d", &a[i].fine);
}
sort(a.begin(), a.end(), checker);
printf("%d", a[0]);
iter(i, 1, n){
printf(" %d", a[i]);
}
printf("\n");
if(tc)
printf("\n");
}
return 0;
}