From e2dde5a36296f19317b780fa07d4f17899072b50 Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Sat, 23 Aug 2025 22:11:40 +0900 Subject: [PATCH] =?UTF-8?q?[20250823]=20PGM=20/=20LV2=20/=20=EC=9D=B4?= =?UTF-8?q?=EB=AA=A8=ED=8B=B0=EC=BD=98=20=ED=95=A0=EC=9D=B8=ED=96=89?= =?UTF-8?q?=EC=82=AC=20/=20=EC=9D=B4=EC=9D=B8=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...40\354\235\270\355\226\211\354\202\254.md" | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 "LiiNi-coder/202508/23 PGM \354\235\264\353\252\250\355\213\260\354\275\230 \355\225\240\354\235\270\355\226\211\354\202\254.md" diff --git "a/LiiNi-coder/202508/23 PGM \354\235\264\353\252\250\355\213\260\354\275\230 \355\225\240\354\235\270\355\226\211\354\202\254.md" "b/LiiNi-coder/202508/23 PGM \354\235\264\353\252\250\355\213\260\354\275\230 \355\225\240\354\235\270\355\226\211\354\202\254.md" new file mode 100644 index 00000000..9d8d76ab --- /dev/null +++ "b/LiiNi-coder/202508/23 PGM \354\235\264\353\252\250\355\213\260\354\275\230 \355\225\240\354\235\270\355\226\211\354\202\254.md" @@ -0,0 +1,74 @@ +```java +import java.util.*; +class Solution { + private static List combs; + private static int[] comb; + private static int[] coupons = new int[]{10, 20, 30, 40}; + private static int NOfE; + public int[] solution(int[][] users, int[] emoticons) { + NOfE = emoticons.length; + combs = new LinkedList(); + comb = new int[NOfE]; + var answer1 = 0; + var answer2 = 0; + //# 이모티콘 부분집합 for ex. 10, 20, 30, 30, 30... 4^7 + getComb(); + for(int[] combE : combs){ + //System.out.println(Arrays.toString(combE)); + int[] candidates = new int[2]; + //## 유저 for문 + int[] prices = new int[NOfE]; + for(int i = 0; i= uPrice){ + //System.out.println("넘음!"); + candidates[0] += 1; + continue outer; + } + } + candidates[1] += uTotal; + } + //System.out.println(String.format("중간결과: %d %d", candidates[0], candidates[1])); + boolean b1 = answer1 <= candidates[0]; + boolean b2 = answer2 <= candidates[1]; + if(answer1 == candidates[0]){ + if(answer2 <= candidates[1]){ + answer2 = candidates[1]; + } + }else if(answer1 < candidates[0]){ + answer1 = candidates[0]; + answer2 = candidates[1]; + } + + //### + } + + return new int[]{answer1, answer2}; + } + private void getComb(){ + dfs(0); + } + private void dfs(int index){ + if(index == NOfE){ + combs.add(comb.clone()); + return; + } + for(int coupon: coupons){ + comb[index] = coupon; + dfs(index+1); + } + } +} +```