|
์ฝ๋ ์์ฑํ๊ธฐ
import math
def solution(progresses, speeds):
answer = []
days=[]
for (i,j) in zip(progresses,speeds):
days.append(math.ceil((100-i)/j))
print(days)
max=days[0]
count=0
for day in days:
if day>max:
answer.append(count)
count=1
max=day
else: count+=1
answer.append(count)
return answer
if __name__=='__main__':
print(solution([93, 30, 55],[1, 30, 5]))
Python
๋ณต์ฌ
|
์ฝ๋ ์ค๋ช
ํ๊ธฐ
1.
๊ฐ ์์
์ ์ํํ๋๋ฐ ๊ฑธ๋ฆฌ๋ day๋ฅผ days๋ฐฐ์ด์ ์ ์ฅํ๋ค.
2.
max ๋ณ์์ days์ ์ฒซ ๋ฒ์งธ ์์๋ฅผ ๋ฃ๊ณ , days ๋ฐฐ์ด์ ์ํํ๋ฉด์ ๋ค์ ๊ณผ์ ์ ์ํํ๋ค.
a.
day๊ฐ max๋ณด๋ค ํฌ๋ค๋ฉด answer๋ฐฐ์ด์ ์ํํ ์์
์ ๊ฐ์ count๋ฅผ ๋ฃ๊ณ , count๋ 1๋ก ์ด๊ธฐํํ๊ณ , max๋ day๋ก ์ด๊ธฐํํ์ฌ ๋ฐฐํฌ๊ณผ์ ์ ์งํํ๋ค.
b.
max๊ฐ day๋ณด๋ค ํฌ๋ค๋ฉด ๋ค์ ์์
๊ณผ ๊ฐ์ ๋ฐฐํฌํ ์ ์์ผ๋ฏ๋ก ์ํ์์
๊ฐ์ count๋ฅผ +1 ํด์ค๋ค.