From de0f75f5764fabd22065030fe367ae61eee378bc Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:29:09 +0900 Subject: [PATCH] =?UTF-8?q?[20250814]=20BOJ=20/=20G5=20/=20=EB=82=98?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=A7=90=EA=B3=A0=EC=82=AC=ED=98=95=20?= =?UTF-8?q?=EC=9D=B8=EA=B0=84=EC=9D=B4=EC=95=BC=20/=20=EA=B9=80=EC=88=98?= =?UTF-8?q?=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...70\352\260\204\354\235\264\354\225\274.md" | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 "suyeun84/202508/14 BOJ G5 \353\202\230\353\212\224 \352\270\260\353\247\220\352\263\240\354\202\254\355\230\225 \354\235\270\352\260\204\354\235\264\354\225\274.md" diff --git "a/suyeun84/202508/14 BOJ G5 \353\202\230\353\212\224 \352\270\260\353\247\220\352\263\240\354\202\254\355\230\225 \354\235\270\352\260\204\354\235\264\354\225\274.md" "b/suyeun84/202508/14 BOJ G5 \353\202\230\353\212\224 \352\270\260\353\247\220\352\263\240\354\202\254\355\230\225 \354\235\270\352\260\204\354\235\264\354\225\274.md" new file mode 100644 index 00000000..fa9428a4 --- /dev/null +++ "b/suyeun84/202508/14 BOJ G5 \353\202\230\353\212\224 \352\270\260\353\247\220\352\263\240\354\202\254\355\230\225 \354\235\270\352\260\204\354\235\264\354\225\274.md" @@ -0,0 +1,62 @@ +```java +import java.io.*; +import java.util.*; + +public class boj23254 { + 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(); + int M = nextInt(); + int answer = 0; + int[] base = new int[M]; + int[] up = new int[M]; + int time = 24 * N; + PriorityQueue pq = new PriorityQueue<>( + (x,y) -> y.plus - x.plus + ); + nextLine(); + for (int i = 0; i < M; i++) { + base[i] = nextInt(); + answer += base[i]; + } + nextLine(); + for (int i = 0; i < M; i++) { + up[i] = nextInt(); + pq.add(new Node(100 - base[i], up[i])); + } + + while(!pq.isEmpty()){ + Node cur = pq.poll(); + + if(time >= (cur.rest / cur.plus)){ + time -= cur.rest / cur.plus; + + answer += cur.plus * (cur.rest / cur.plus); + + if(cur.rest % cur.plus >= 1){ + pq.add(new Node(cur.rest % cur.plus,cur.rest % cur.plus)); + } + }else if(time > 0 && (cur.rest >= time * cur.plus)){ + answer += time * cur.plus; + time = 0; + } + } + + System.out.println(answer); + } + static class Node{ + int rest; + int plus; + + Node(int rest,int plus){ + this.rest = rest; + this.plus = plus; + } + } +} +```