[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค-Lv2] ๊ธฐ๋Šฅ๊ฐœ๋ฐœ

๐Ÿ“š Problem Solving/Programmers

 

์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๊ธฐ๋Šฅ๊ฐœ๋ฐœ

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ํŒ€์—์„œ๋Š” ๊ธฐ๋Šฅ ๊ฐœ์„  ์ž‘์—…์„ ์ˆ˜ํ–‰ ์ค‘์ž…๋‹ˆ๋‹ค. ๊ฐ ๊ธฐ๋Šฅ์€ ์ง„๋„๊ฐ€ 100%์ผ ๋•Œ ์„œ๋น„์Šค์— ๋ฐ˜์˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜, ๊ฐ ๊ธฐ๋Šฅ์˜ ๊ฐœ๋ฐœ์†๋„๋Š” ๋ชจ๋‘ ๋‹ค๋ฅด๊ธฐ ๋•Œ๋ฌธ์— ๋’ค์— ์žˆ๋Š” ๊ธฐ๋Šฅ์ด ์•ž์— ์žˆ๋Š”

programmers.co.kr

import sys

input = sys.stdin.readline

progresses = list(map(int, input().split()))
speeds = list(map(int, input().split()))


def solution(progresses, speeds):
    answer = []
    while len(progresses) > 0:
        for i in range(len(progresses)):
            progresses[i] += speeds[i]
        if progresses[0] >= 100:
            cnt = 0
            while len(progresses) > 0 and progresses[0] >= 100:
                progresses.pop(0)
                speeds.pop(0)
                cnt += 1
            answer.append(cnt)
    return answer


print(solution(progresses, speeds))

 

ํ•ด์„ค

progresses์˜ ๊ฐ’์„ speeds์˜ ๊ฐ’๋งŒํผ ๋”ํ•ด์ค€๋‹ค.

progresses์˜ ์ฒซ ๋ฒˆ์งธ ๊ฐ’์ด 100 ์ด์ƒ์ด๋ฉด ์ฒซ ๋ฒˆ์งธ ๊ฐ’์ด 100๋ณด๋‹ค ์ž‘์„ ๋•Œ๊นŒ์ง€ pop์„ ์‹œ์ผœ์ฃผ๊ณ , ๊ทธ ํšŸ์ˆ˜๋ฅผ answer์— ์ €์žฅํ•œ๋‹ค.