-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path10026.cpp
More file actions
59 lines (47 loc) · 942 Bytes
/
10026.cpp
File metadata and controls
59 lines (47 loc) · 942 Bytes
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>
#include <cstdint>
using namespace std;
struct Job_t {
int64_t time;
int64_t fine;
int64_t position;
};
void solve();
bool comparison(const Job_t &job1, const Job_t &job2);
int64_t numCases;
int64_t numInputs;
Job_t temp;
vector<Job_t> jobs;
int main() {
cin >> numCases;
for (int64_t i = 0; i < numCases; i++) {
if (i) {
cout << endl;
}
cin >> numInputs;
solve();
}
return 0;
}
void solve() {
jobs.clear();
jobs.reserve(numInputs);
for (int64_t i = 1; i <= numInputs; i++) {
cin >> temp.time >> temp.fine;
temp.position = i;
jobs.push_back(temp);
}
stable_sort(jobs.begin(), jobs.end(), comparison);
for (int64_t i = 0; i < numInputs; i++) {
if (i) {
cout << " ";
}
cout << jobs[i].position;
}
cout << endl;
}
bool comparison(const Job_t &job1, const Job_t &job2) {
return ((job1.time * job2.fine) < (job2.time * job1.fine));
}