diff --git "a/Ukj0ng/202601/13 BOJ G1 \352\265\254\353\221\220 \354\210\230\354\204\240\352\263\265.md" "b/Ukj0ng/202601/13 BOJ G1 \352\265\254\353\221\220 \354\210\230\354\204\240\352\263\265.md" new file mode 100644 index 00000000..f4f189db --- /dev/null +++ "b/Ukj0ng/202601/13 BOJ G1 \352\265\254\353\221\220 \354\210\230\354\204\240\352\263\265.md" @@ -0,0 +1,55 @@ +``` +import java.io.*; +import java.util.*; + +public class Main { + private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + private static PriorityQueue pq; + private static int[][] task; + private static int N; + + public static void main(String[] args) throws IOException { + init(); + + while (!pq.isEmpty()) { + bw.write(pq.poll().index + " "); + } + bw.flush(); + bw.close(); + br.close(); + } + + private static void init() throws IOException { + N = Integer.parseInt(br.readLine()); + task = new int[N+1][2]; + + for (int i = 1; i <= N; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + task[i][0] = Integer.parseInt(st.nextToken()); + task[i][1] = Integer.parseInt(st.nextToken()); + } + + pq = new PriorityQueue<>((o1, o2) -> { + if (o1.val != o2.val) return Double.compare(o2.val, o1.val); + return Integer.compare(o1.index, o2.index); + }); + + for (int i = 1; i <= N; i++) { + pq.add(new Task(i, (double)task[i][1]/task[i][0], task[i][0])); + } + } + + static class Task { + int index; + double val; + int time; + + public Task(int index, double val, int time) { + this.index = index; + this.val = val; + this.time = time; + } + } +} +```