Skip to content

Commit

Permalink
Merge pull request #142 from AlgoLeadMe/40-tgyuuAn
Browse files Browse the repository at this point in the history
40-tgyuuAn
  • Loading branch information
tgyuuAn authored Mar 4, 2024
2 parents 68f3286 + 3717228 commit df1db55
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 @@ -41,4 +41,5 @@
| 37μ°¨μ‹œ | 2023.02.04 | BFS | <a href="https://www.acmicpc.net/problem/1039">κ΅ν™˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/131
| 38μ°¨μ‹œ | 2023.02.15 | DP | <a href="https://www.acmicpc.net/problem/2749">ν”Όλ³΄λ‚˜μΉ˜ 수 3</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/137
| 39μ°¨μ‹œ | 2023.02.18 | DP | <a href="https://www.acmicpc.net/problem/7579">μ•±</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/139
| 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 df1db55

Please sign in to comment.