Skip to content

Commit

Permalink
2024-02-21
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Feb 20, 2024
1 parent af790fe commit 1d06d18
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tgyuuAn/DP/μž…λŒ€.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys

remain_days, need_score = map(int,sys.stdin.readline().split())
volunteer_scores = [0]
volunteer_scores.extend(list(map(int,sys.stdin.readline().split())))

blood_donation_score, blood_donation_break_time = map(int,sys.stdin.readline().split())

volunteer_scores.extend([0 for _ in range(blood_donation_break_time-1)])
maximum_blood_donation_count = (len(volunteer_scores)+blood_donation_break_time-1)//blood_donation_break_time+1

dp_table = [[0 for _ in range(maximum_blood_donation_count)] for _ in range(len(volunteer_scores))]

for date in range(len(volunteer_scores)):
if date >= blood_donation_break_time:
for blood_donation_count in range(1,maximum_blood_donation_count):
dp_table[date][blood_donation_count] = max(dp_table[date][blood_donation_count],
dp_table[date-1][blood_donation_count] + volunteer_scores[date],
dp_table[date-blood_donation_break_time][blood_donation_count-1] + blood_donation_score)

dp_table[date][0] = dp_table[date-1][0] + volunteer_scores[date]

print(dp_table)

for count in range(len(dp_table[-1])):
if dp_table[-1][count] >= need_score:
print(count)
break

else: print(-1)
1 change: 1 addition & 0 deletions tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@
| 35μ°¨μ‹œ | 2023.01.25 | 이뢄 탐색 | <a href="https://www.acmicpc.net/problem/2110">곡유기 μ„€μΉ˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/120
| 36μ°¨μ‹œ | 2023.02.04 | BFS | <a href="https://www.acmicpc.net/problem/4991">λ‘œλ΄‡ μ²­μ†ŒκΈ°</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/126
| 37μ°¨μ‹œ | 2023.02.04 | BFS | <a href="https://www.acmicpc.net/problem/1039">κ΅ν™˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/131
| 40μ°¨μ‹œ | 2023.02.21 | DP | <a href="https://www.acmicpc.net/problem/31413">μž…λŒ€</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/142
---

0 comments on commit 1d06d18

Please sign in to comment.