Skip to content

Commit 279f987

Browse files
authored
Merge pull request #1790 from AlgorithmWithGod/Ukj0ng
[20260113] BOJ / G1 / 구두 수선공 / 한종욱
2 parents 1ac080a + e4d62fd commit 279f987

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
```
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+
private static PriorityQueue<Task> pq;
9+
private static int[][] task;
10+
private static int N;
11+
12+
public static void main(String[] args) throws IOException {
13+
init();
14+
15+
while (!pq.isEmpty()) {
16+
bw.write(pq.poll().index + " ");
17+
}
18+
bw.flush();
19+
bw.close();
20+
br.close();
21+
}
22+
23+
private static void init() throws IOException {
24+
N = Integer.parseInt(br.readLine());
25+
task = new int[N+1][2];
26+
27+
for (int i = 1; i <= N; i++) {
28+
StringTokenizer st = new StringTokenizer(br.readLine());
29+
task[i][0] = Integer.parseInt(st.nextToken());
30+
task[i][1] = Integer.parseInt(st.nextToken());
31+
}
32+
33+
pq = new PriorityQueue<>((o1, o2) -> {
34+
if (o1.val != o2.val) return Double.compare(o2.val, o1.val);
35+
return Integer.compare(o1.index, o2.index);
36+
});
37+
38+
for (int i = 1; i <= N; i++) {
39+
pq.add(new Task(i, (double)task[i][1]/task[i][0], task[i][0]));
40+
}
41+
}
42+
43+
static class Task {
44+
int index;
45+
double val;
46+
int time;
47+
48+
public Task(int index, double val, int time) {
49+
this.index = index;
50+
this.val = val;
51+
this.time = time;
52+
}
53+
}
54+
}
55+
```

0 commit comments

Comments
 (0)