[ 2023-07-09 ๐Ÿ”ซ TIL ]

Burkeyยท2023๋…„ 7์›” 9์ผ
0

TIL

๋ชฉ๋ก ๋ณด๊ธฐ
116/157

๋ฐฑ์ค€ 11047๋ฒˆ ํŒŒ์ด์ฌ


๋ฌธ์ œ


์ฝ”๋“œ

import sys

input = sys.stdin.readline

n, k = map(int, input().split())
cost_li = []

for _ in range(n):
  cost = int(input())
  if (cost <= k): # k๊ฐ’ ์ด์ƒ์ด๋ฉด ํ•„์š”์—†๊ธฐ์— ๋ฐฐ์—ด์— ์•ˆ๋„ฃ์Œ
    cost_li.append(cost)
    
# ํฐ ์ˆ˜๋กœ ๋‚˜๋ˆ„์–ด ์งˆ ๋•Œ๊ฐ€ ๊ฒฝ์šฐ์˜ ์ˆ˜๊ฐ€ ์ตœ์†Œ์ผ ๋•Œ์ด๋‹ค.
cost_li = reversed(cost_li) # ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ๋ฐ”๋€œ
count = 0

for cost in cost_li:
  if (k - cost) >= 0: 
    m = k // cost
    k = k - (cost * m)
    count += m
print(count)
profile
์Šคํƒฏ ์˜ฌ๋ฆฌ๋Š” ์ค‘

0๊ฐœ์˜ ๋Œ“๊ธ€