From 7dcc2d69b28070e822acc04013a65016e2b55599 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sun, 18 Feb 2024 06:26:36 +0900 Subject: [PATCH] 2024-02-18 --- "tgyuuAn/DP/\354\225\261.py" | 16 ++++++++++++++++ tgyuuAn/README.md | 1 + 2 files changed, 17 insertions(+) create mode 100644 "tgyuuAn/DP/\354\225\261.py" diff --git "a/tgyuuAn/DP/\354\225\261.py" "b/tgyuuAn/DP/\354\225\261.py" new file mode 100644 index 00000000..a362acdc --- /dev/null +++ "b/tgyuuAn/DP/\354\225\261.py" @@ -0,0 +1,16 @@ +total_app_count, need_memory = map(int,input().split()) + +use_memory = list(map(int,input().split())) +re_use_cost = list(map(int,input().split())) + +dp_table = [0 for _ in range(sum(re_use_cost)+1)] +cost_sum = sum(re_use_cost) + +for memory, cost in zip(use_memory, re_use_cost): + for idx in range(cost_sum,cost-1,-1): + dp_table[idx] = max(dp_table[idx], dp_table[idx-cost] + memory) + +for idx, memory in enumerate(dp_table): + if memory >= need_memory: + print(idx) + break \ No newline at end of file diff --git a/tgyuuAn/README.md b/tgyuuAn/README.md index 6e5688b1..cdc527cf 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -39,4 +39,5 @@ | 35차시 | 2023.01.25 | 이분 탐색 | 공유기 설치 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/120 | 36차시 | 2023.02.04 | BFS | 로봇 청소기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/126 | 37차시 | 2023.02.04 | BFS | 교환 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/131 +| 38차시 | 2023.02.18 | DP | | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/139 ---