From d41b3d59e36a5cc28f4d66136deb4fcd5e08ca4a Mon Sep 17 00:00:00 2001 From: Heo Nayeong Date: Sun, 3 Mar 2024 20:41:05 +0900 Subject: [PATCH] 24-gjsk132 --- ...251\354\262\264 \353\206\200\354\235\264.py" | 17 +++++++++++++++++ gjsk132/README.md | 1 + 2 files changed, 18 insertions(+) create mode 100644 "gjsk132/Greedy/15903 \354\271\264\353\223\234 \355\225\251\354\262\264 \353\206\200\354\235\264.py" diff --git "a/gjsk132/Greedy/15903 \354\271\264\353\223\234 \355\225\251\354\262\264 \353\206\200\354\235\264.py" "b/gjsk132/Greedy/15903 \354\271\264\353\223\234 \355\225\251\354\262\264 \353\206\200\354\235\264.py" new file mode 100644 index 0000000..72937bb --- /dev/null +++ "b/gjsk132/Greedy/15903 \354\271\264\353\223\234 \355\225\251\354\262\264 \353\206\200\354\235\264.py" @@ -0,0 +1,17 @@ +import heapq as hp + +input = open(0).readline + +card_cnt, merge_cnt = map(int, input().split()) + +card_num = list(map(int,input().split())) + +hp.heapify(card_num) + +for i in range(merge_cnt): + + a, b = hp.heappop(card_num), hp.heappop(card_num) + hp.heappush(card_num, a+b) + hp.heappush(card_num, a+b) + +print(sum(card_num)) \ No newline at end of file diff --git a/gjsk132/README.md b/gjsk132/README.md index 666f739..74c365f 100644 --- a/gjsk132/README.md +++ b/gjsk132/README.md @@ -23,3 +23,4 @@ | 21μ°¨μ‹œ | 2024.02.11 | DP | [3067 Coins](https://www.acmicpc.net/problem/3067) | [πŸͺ™](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/102) | | 22μ°¨μ‹œ | 2024.02.15 | Brute Froce | [1107 리λͺ¨μ»¨](https://www.acmicpc.net/problem/1107) | [πŸ“²](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/106) | | 23μ°¨μ‹œ | 2024.02.27 | Sort | [18870 μ’Œν‘œ μ••μΆ•](https://www.acmicpc.net/problem/18870) | [πŸ“Œ](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/117) | +| 23μ°¨μ‹œ | 2024.03.03 | Greedy | [15903 μΉ΄λ“œ 합체 놀이](https://www.acmicpc.net/problem/159030]) | [πŸƒ](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/122) |