diff --git a/pknujsp/README.md b/pknujsp/README.md index 9a9e4162..99ad2452 100644 --- a/pknujsp/README.md +++ b/pknujsp/README.md @@ -34,4 +34,6 @@ | 30차시 | 2024.01.23 | DP | [ABBC](https://www.acmicpc.net/problem/25381) | [#119](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/119) | | 31차시 | 2024.01.30 | SORT | [멀티버스 Ⅱ](https://www.acmicpc.net/problem/18869) | [#123](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/123) | | 32차시 | 2024.02.04 | BFS | [숨바꼭질 3](https://www.acmicpc.net/problem/13549) | [#127](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/127) | -| 33차시 | 2024.02.06 | 큐 | [철로](https://www.acmicpc.net/problem/13334) | [#132](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/132) | \ No newline at end of file +| 33차시 | 2024.02.06 | 큐 | [철로](https://www.acmicpc.net/problem/13334) | [#132](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/132) | +| 34차시 | 2024.02.12 | BFS | [이분 그래프](https://www.acmicpc.net/problem/1707) | [#135](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/135) | +| 35차시 | 2024.02.14 | 그리디 | [선물할인](https://www.acmicpc.net/problem/25947) | [#137](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/137) | diff --git "a/pknujsp/\352\267\270\353\246\254\353\224\224/35-\354\204\240\353\254\274\355\225\240\354\235\270.py" "b/pknujsp/\352\267\270\353\246\254\353\224\224/35-\354\204\240\353\254\274\355\225\240\354\235\270.py" new file mode 100644 index 00000000..85520b1e --- /dev/null +++ "b/pknujsp/\352\267\270\353\246\254\353\224\224/35-\354\204\240\353\254\274\355\225\240\354\235\270.py" @@ -0,0 +1,36 @@ +from sys import * + +n, budget, max_sales = map(int, stdin.readline().split()) +gifts = sorted(list(map(int, stdin.readline().split()))) + +min_price_gift = max_price_gift = 0 +prices = 0 +sales = 0 + +for sale_gift in range(max_sales): + prices += gifts[sale_gift] // 2 + max_price_gift += 1 + + if prices > budget: + print(sale_gift) + exit() + +sales = max_price_gift - min_price_gift +while max_price_gift < n: + if sales < max_sales or max_sales == 0: + if max_sales == 0: + prices += gifts[max_price_gift] + else: + prices += gifts[max_price_gift] // 2 + + if prices > budget: + break + + max_price_gift += 1 + sales += 1 + else: + prices += gifts[min_price_gift] // 2 + min_price_gift += 1 + sales -= 1 + +print(max_price_gift)