Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions boj/Random Defense/1475_seulbeen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 방 번호
# 21분
# Counter 써서 6,9 개수만 2로 나눠주면 될거 같다고 생각했는데, 굳이 그렇게 안해도 될것 같음

import sys
from collections import Counter
input=sys.stdin.readline

room_num=input().rstrip()
# print(room_num)
total=[0]*10

for i in room_num:
check=int(i)
# 숫자가 6이나 9인 경우에는 서로 땜빵이 가능하니 적은 쪽 숫자에 +1
if check==6 or check==9:
if total[6]<=total[9]:
total[6]+=1
else:
total[9]+=1
# 다른 숫자들은 필요할때마다 세트가 필요함
else:
total[check]+=1


print(max(total))


27 changes: 27 additions & 0 deletions boj/Random Defense/1535_seulbeen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 1535
# 구글링
# 0-1 배낭문제(dp)
import sys
input=sys.stdin.readline

n=int(input())
hp=[0]+list(map(int,input().split()))
happy=[0]+list(map(int,input().split()))

# 2차원 dp 배열
# dp[i][j]= 체력 J에 I번 사람까지 탐색했을때 최대 행복
dp=[[0]*101 for _ in range(n+1)]

for i in range(n+1):
for j in range(101):
# 체력이 남았으면
if j-hp[i]>=0:
# dp[i-1][j]: 감사인사를 안하는 경우
# dp[i-1][j-hp[i]]+ happy[i] : 체력을 깎아서 인사 하는 경우
dp[i][j]=max(dp[i-1][j],dp[i-1][j-hp[i]]+happy[i])
# 체력이 남지 않았으면 이전 사람 dp 값 유지
else:
dp[i][j]=dp[i-1][j]
# print(hp)
# print(dp)
print(dp[n][99])