https://school.programmers.co.kr/learn/courses/30/lessons/388351
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr

def solution(schedules, timelogs, startday):
# 출근 희망 시각 : schedules : shape : (n)
# 출근한 시각 : timelogs : (n, 7)
# 이벤트 시작 요일 startday 1 : 월 ~ 7 : 일, 6, 7 : 주말
# 주말은 이벤트 영향 X
answer = 0
for person in range(len(schedules)) :
sch_h, sch_m = schedules[person]//100, schedules[person]%100
p_timelogs = [(timelog//100, timelog%100) for timelog in timelogs[person]]
# 10분 인정 시각
max_m = sch_m + 10
new_h, new_m = sch_h + max_m // 60, max_m % 60
# 24시 체크
new_h = new_h % 24
# check timelogs
today = startday
flag = True
for tl in p_timelogs :
# 주말은 스킵
if today == 6 or today == 7 :
today = 1 if today == 7 else (today + 1)
continue
# 주중 체크
today += 1
# 10분 차이인지
if tl[0] > new_h or (tl[0] >= new_h and tl[1] > new_m) :
flag = False
break
if flag : answer += 1
return answer
아이디어
schedules[i]에서 10분 더한 시간 저장 (new_h,new_m)startday부터 오늘 날짜를 세어, 주말이면 넘기고, 주중일 때만 계산timelogs의 시간이new_h시간보다 단순하게 큰 경우, 10분 차이를 넘긴 경우 해당 사람 케이스 넘김
'코테풀이 > 프로그래머스' 카테고리의 다른 글
| [PCCP 기출문제] 1번 / 동영상 재생기 (0) | 2025.05.12 |
|---|---|
| [LV. 1] 택배 상자 꺼내기 (1) | 2025.05.10 |