๐Ÿ‘ฉ‍๐Ÿ’ปStudy Group/๐Ÿซง2021-2022 ๋™๊ณ„ ๋ชจ๊ฐ์ฝ”_์Šˆ๋ถ•ํŒฅ๋ถ•

01์›” 18์ผ ๋ชจ๊ฐ์ฝ”_์Šˆ๋ถ•ํŒฅ๋ถ• 5ํšŒ์ฐจ ๊ฒฐ๊ณผ ๋ณด๊ณ ์„œ

๋ฟŒ์•ผ._. 2022. 1. 18. 23:26

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