From 132005eaf99903ce338eb69ff2af506b1da0f76e Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Sun, 15 Jun 2025 18:00:06 +0900 Subject: [PATCH] =?UTF-8?q?[20250615]=20BOJ=20/=20G3=20/=20=EA=B3=B5?= =?UTF-8?q?=EC=A3=BC=EB=8B=98=EC=9D=98=20=EC=A0=95=EC=9B=90=20/=20?= =?UTF-8?q?=EA=B9=80=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\235\230 \354\240\225\354\233\220.md" | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 "suyeun84/202506/15 BOJ G3 \352\263\265\354\243\274\353\213\230\354\235\230 \354\240\225\354\233\220.md" diff --git "a/suyeun84/202506/15 BOJ G3 \352\263\265\354\243\274\353\213\230\354\235\230 \354\240\225\354\233\220.md" "b/suyeun84/202506/15 BOJ G3 \352\263\265\354\243\274\353\213\230\354\235\230 \354\240\225\354\233\220.md" new file mode 100644 index 00000000..afde869f --- /dev/null +++ "b/suyeun84/202506/15 BOJ G3 \352\263\265\354\243\274\353\213\230\354\235\230 \354\240\225\354\233\220.md" @@ -0,0 +1,54 @@ +```java +import java.io.*; +import java.util.*; + +public class boj2457 { + 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());} + + public static void main(String[] args) throws Exception { + nextLine(); + int N = nextInt(); + Flower[] flowers = new Flower[N]; + for (int i = 0; i < N; i++) { + nextLine(); + flowers[i] = new Flower(nextInt()*100 + nextInt(), nextInt()*100 + nextInt()); + } + Arrays.sort(flowers, (o1, o2)-> { + if (o1.start == o2.start) return o2.end - o1.end; + return o1.start - o2.start; + }); + int start = 301; + int end = 1201; + int maxEnd = 0; + int answer = 0; + int idx = 0; + while (start < end) { + boolean flag = false; + for (int i = idx; i < N; i++) { + if (flowers[i].start > start) break; + if (flowers[i].end > maxEnd) { + maxEnd = flowers[i].end; + idx = i+1; + flag = true; + } + } + if (flag) { + answer++; + start = maxEnd; + } else break; + } + System.out.println(maxEnd < end ? "0" : answer); + } + + static class Flower { + int start, end; + public Flower (int start, int end) { + this.start = start; + this.end = end; + } + } +} +```