def solution(new_id):
#1단계
new_id1 = new_id.lower()
#2단계
new_id2=''
for x in new_id1:
if x.isalpha() or x.isdigit() or x=='-' or x=='_' or x=='.':
new_id2+=x
#3단계
while '..' in new_id2:
new_id2 = new_id2.replace('..','.')
#4단계
new_id3=list(new_id2)
if new_id3 and new_id3[0]=='.': del new_id3[0]
if new_id3 and new_id3[-1]=='.':del new_id3[-1]
new_id4 = ''.join(new_id3)
#5단계
if new_id4=='': return 'aaa'
#6단계
if len(new_id4)>=16: new_id4 = new_id4[:15]
if new_id4[-1]=='.': new_id4 = new_id4[:14]
#7단계
if len(new_id4)<3:
while len(new_id4)!=3:
new_id4+=new_id4[-1]
return new_id4
예를들어 n=5, k=17 일떼, 수빈이가 5-10-9-18-17 순으로 가면 4번 만에 동생을 찾을 수 있다.
풀이
from collections import deque
MAX=10**5
dp=[0]*(MAX+1)
dq = deque()
n,k = map(int,input().split())
dq.append(n)
while dq:
c=dq.popleft() #current
if c==k:
print(dp[k])
break
for nc in (c-1,c+1,c*2):
if 0<=nc<=MAX and dp[nc]==0:
dp[nc]=dp[c]+1
dq.append(nc)
n,k = map(int,input().split())
coin=[0]*n
for i in range(n):
coin[i]=int(input())
cnt=tmp=0
for i in range(n-1,-1,-1):
if k>=coin[i] :
tmp=k//coin[i]
k-=(tmp*coin[i])
if tmp==0: cnt+=1
else: cnt+=tmp
print(cnt)