2022๋ 01์ 18์ผ ํ์์ผ 20:30~23:30
๐ฅ ๋ ธ๋ ๋ฆฌ์กํธ ๊ธฐ์ด ๊ฐ์ ๋ฃ๊ธฐ ๐ฅ
๋ฆฌ์กํธ ์ค์ , ๊ธฐ์ด์ ๋ํด์ ๊ฐ์๋ฅผ ์๊ฐํ์๋ค.
๐ฅ Programmers ๋ฌธ์ ํด๊ฒฐ ๐ฅ
โ 2022 KAKAO BLIND RECRUITMENT_ ์ฃผ์ฐจ ์๊ธ ๊ณ์ฐ_ Python
https://programmers.co.kr/learn/challenges
- ๋ฌธ์ ํ์ด
def solution(fees, records):
answer = []
dict={} # ์ฐจ ๋ฒํธ: ๋์ ์ฃผ์ฐจ ์๊ฐ
temp={} # ์ฐจ ๋ฒํธ: ์
์ฐจ ์๊ฐ
for i in records:
x=i.split()
if x[2]=="IN":
if x[1] not in dict:
dict[x[1]]=0
temp[x[1]]=x[0] # ์
์ฐจ ์๊ฐ
else: #์๊ฐ ๊ณ์ฐ
outtime=list(map(int,x[0].split(":")))
intime=list(map(int, temp[x[1]].split(":")))
del temp[x[1]]
time=(outtime[0]-intime[0])*60+(outtime[1]-intime[1])
dict[x[1]]+=time
for key,value in temp.items(): #23:59๋ถ ์ถ์ฐจ
intime=list(map(int, value.split(":")))
outtime=[23,59]
time=(outtime[0]-intime[0])*60+(outtime[1]-intime[1])
dict[key]+=time
for key,value in dict.items():
result=fees[1] #๊ธฐ๋ณธ ์๊ธ
if value-fees[0]>0: #๊ธฐ๋ณธ ์๊ธ ์ด๊ณผ์
if (value-fees[0])%fees[2]!=0:
result+=(((value-fees[0])//fees[2])+1)*fees[3]
else:
result+=((value-fees[0])//fees[2])*fees[3]
dict[key]=result # ์ฐจ ๋ฒํธ: ์ฃผ์ฐจ ์๊ธ
dict=sorted(dict.items()) #์ฐจ๋ ๋ฒํธ๊ฐ ์์ ์๋์ฐจ๋ถํฐ
for i in dict: #list
answer.append(i[1])
return answer
'๐ฉโ๐ปStudy Group > ๐ซง2021-2022 ๋๊ณ ๋ชจ๊ฐ์ฝ_์๋ถํฅ๋ถ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
01์ 20์ผ ๋ชจ๊ฐ์ฝ_์๋ถํฅ๋ถ 6ํ์ฐจ ๊ฒฐ๊ณผ ๋ณด๊ณ ์ (0) | 2022.01.20 |
---|---|
01์20์ผ ๋ชจ๊ฐ์ฝ_์๋ถํฅ๋ถ 6ํ์ฐจ ๊ณํ (0) | 2022.01.20 |
01์18์ผ ๋ชจ๊ฐ์ฝ_์๋ถํฅ๋ถ 5ํ์ฐจ ๊ณํ (0) | 2022.01.18 |
01์ 13์ผ ๋ชจ๊ฐ์ฝ_์๋ถํฅ๋ถ 4ํ์ฐจ ๊ฒฐ๊ณผ ๋ณด๊ณ ์ (0) | 2022.01.13 |
01์13์ผ ๋ชจ๊ฐ์ฝ_์๋ถํฅ๋ถ 4ํ์ฐจ ๊ณํ (0) | 2022.01.13 |