diff --git "a/suyeun84/202507/28 BOJ G5 \352\260\200\355\235\254\354\231\200 \355\224\204\353\241\234\354\204\270\354\212\244 1.md" "b/suyeun84/202507/28 BOJ G5 \352\260\200\355\235\254\354\231\200 \355\224\204\353\241\234\354\204\270\354\212\244 1.md" new file mode 100644 index 00000000..66bb65d8 --- /dev/null +++ "b/suyeun84/202507/28 BOJ G5 \352\260\200\355\235\254\354\231\200 \355\224\204\353\241\234\354\204\270\354\212\244 1.md" @@ -0,0 +1,57 @@ +```java +import java.io.*; +import java.util.*; + +public class boj21773 { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + + public static void main(String[] args) throws Exception { + nextLine(); + int T = nextInt(); + int n = nextInt(); + PriorityQueue pq = new PriorityQueue<>(); + for (int i = 0; i < n; i++) { + nextLine(); + int a = nextInt(); + int b = nextInt(); + int c = nextInt(); + pq.add(new Process(a, b, c)); + } + + for (int i = 0; i < T; i++) { + if (pq.isEmpty()) break; + Process process = pq.poll(); + bw.write(process.id + "\n"); + + process.time -= 1; + if (process.time > 0) { + process.level -= 1; + pq.add(process); + } + } + bw.flush(); + } + + static class Process implements Comparable { + int id; + int time; + int level; + + public Process(int id, int time, int level) { + this.id = id; + this.time = time; + this.level = level; + } + @Override + public int compareTo(Process o) { + if (level == o.level) + return id - o.id; + return o.level - level; + } + } +} +```