From 10db255c28aa16ae0f3864fc455845d5919a8454 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Sun, 17 Aug 2025 15:53:27 +0900 Subject: [PATCH] =?UTF-8?q?[20250817]=20BOJ=20/=20G5=20/=20=EB=82=B4?= =?UTF-8?q?=EC=9D=BC=20=ED=95=A0=EA=B1=B0=EC=95=BC=20/=20=EA=B9=80?= =?UTF-8?q?=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4 \355\225\240\352\261\260\354\225\274.md" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "suyeun84/202508/17 BOJ G5 \353\202\264\354\235\274 \355\225\240\352\261\260\354\225\274.md" diff --git "a/suyeun84/202508/17 BOJ G5 \353\202\264\354\235\274 \355\225\240\352\261\260\354\225\274.md" "b/suyeun84/202508/17 BOJ G5 \353\202\264\354\235\274 \355\225\240\352\261\260\354\225\274.md" new file mode 100644 index 00000000..d4b0ece4 --- /dev/null +++ "b/suyeun84/202508/17 BOJ G5 \353\202\264\354\235\274 \355\225\240\352\261\260\354\225\274.md" @@ -0,0 +1,41 @@ +```java +import java.io.*; +import java.util.*; + +public class boj7983 { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringTokenizer st; + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws Exception { + nextLine(); + int n = nextInt(); + Task[] task = new Task[n]; + for (int i = 0; i < n; i++) { + nextLine(); + int d = nextInt(); + int t = nextInt(); + task[i] = new Task(d, t); + } + Arrays.sort(task, (o1, o2) -> { + return o2.end - o1.end; + }); + + int answer = task[0].end; + for(int i = 0; i < n; i++) { + if(task[i].end <= answer) answer = task[i].end - task[i].time; + else answer -= task[i].time; + } + System.out.println(answer); + } + static class Task { + int time, end; + public Task(int time, int end) { + this.time = time; + this.end = end; + } + } +} +```