diff --git "a/lkhyun/202510/06 PGM Lv2 \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/lkhyun/202510/06 PGM Lv2 \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..471f1411 --- /dev/null +++ "b/lkhyun/202510/06 PGM Lv2 \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,49 @@ +```java +class Solution { + static int maxCnt = 0; + static int maxSell = 0; + public int[] solution(int[][] users, int[] emoticons) { + saleCase(users, emoticons, 0, 0, new int[emoticons.length]); + return new int[]{maxCnt,maxSell}; + } + public void saleCase(int[][] users, int[] emoticons, int start, int count, int[] selected){ + if(count == emoticons.length){ + int curCnt = 0; + int curSell = 0; + int[] adaption = adaptSale(emoticons,selected); + for(int[] user : users){ + int userTotal = 0; + for(int i=0;i= user[0]){ + userTotal += adaption[i]; + } + } + if(userTotal >= user[1]){ + curCnt++; + }else{ + curSell += userTotal; + } + } + if(maxCnt < curCnt){ + maxCnt = curCnt; + maxSell = curSell; + }else if(maxCnt == curCnt){ + maxSell = Math.max(maxSell,curSell); + } + return; + } + + for(int i=1;i<=4;i++){ + selected[start] = i*10; + saleCase(users,emoticons,start+1,count+1,selected); + } + } + public int[] adaptSale(int[] price, int[] rate){ + int[] adaption = new int[price.length]; + for(int i=0;i