From 7bda6c90970170b7b0d5ac0b1a87d4a7803101d1 Mon Sep 17 00:00:00 2001 From: asqwklop12 <33236685+asqwklop12@users.noreply.github.com> Date: Sat, 7 Mar 2026 15:48:53 +0900 Subject: [PATCH] =?UTF-8?q?=ED=9E=8C=ED=8A=B8=20=EC=8A=A4=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Main.java" | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 "pr/\355\236\214\355\212\270 \354\212\244\355\205\214\354\235\264\354\247\200/Main.java" diff --git "a/pr/\355\236\214\355\212\270 \354\212\244\355\205\214\354\235\264\354\247\200/Main.java" "b/pr/\355\236\214\355\212\270 \354\212\244\355\205\214\354\235\264\354\247\200/Main.java" new file mode 100644 index 0000000..c364a19 --- /dev/null +++ "b/pr/\355\236\214\355\212\270 \354\212\244\355\205\214\354\235\264\354\247\200/Main.java" @@ -0,0 +1,48 @@ +class Solution { + int[] buy; + int total; + int[][] cost; + int[][] hint; + int answer; + public int solution(int[][] cost, int[][] hint) { + answer = Integer.MAX_VALUE; + this.cost = cost; + this.hint = hint; + total = cost.length; + buy = new int[total]; + dfs(0,0); + return answer; + } + + public void dfs(int stage,int price) { + if(stage == total) { + answer = Math.min(answer,price); + return; + } + + int hitBuy = Math.min(buy[stage], total - 1); + + dfs(stage+1, price + cost[stage][hitBuy]); + + if(stage < total -1) { + int[] c = hint[stage]; + // 힌트권을 + // 구매하는 경우 + int cc = price + cost[stage][hitBuy] + c[0]; + + for(int i = 1; i