본문 바로가기
알고리즘/프로그래머스

과제 진행하기

by 1.5볼트 2023. 4. 3.
728x90

https://school.programmers.co.kr/learn/courses/30/lessons/176962

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

문제를 잘못 이해했다

시간이 많이 걸렸다

이런

화가 난다

def solution(t1):
    t1.sort(key=lambda x:x[1])
    t1=list(map(lambda x:[x[0],int(x[1].split(":")[0])*60+int(x[1].split(":")[1]),x[2]],t1))
    t3=[]
    t2=[]
    lll=0
    while len(t1)!=1:
        a=t1[0][1]+int(t1[0][2])
        b=t1[1][1]
        if a<=b:
            ll=t1.pop(0)
            if t2 :
                lll+=int(ll[-1])
            t3.append(ll)
            while t2 and a<b:
                a1=t2[-1][1]+int(t2[-1][-1])
                if a1+lll<=b:
                    ll=t2.pop()
                    lll+=int(ll[-2])
                    t3.append(ll)
                else:
                    break
        else:
            ll=t1.pop(0)
            ll.append(int(ll[-1])-lll)
            t2.append(ll)
            
    return list(map(lambda x:x[0],t3+t1+t2[::-1]))

 

'알고리즘 > 프로그래머스' 카테고리의 다른 글

연속된 부분 수열의 합  (0) 2023.04.08
N개의 최소공배수  (0) 2023.04.05
저자 별 카테고리 별 매출액 집계하기  (0) 2023.04.02
주식가격  (0) 2023.04.01
영어 끝말잇기  (0) 2023.03.31

댓글