반응형
문제
https://www.acmicpc.net/problem/25593
해설
문자열 파싱과 해시 사용이 핵심이었다.
def solution(schedule):
work_time = [4, 6, 4, 10]
schedule_dict = dict()
for i, s in enumerate(schedule):
work = work_time[i % 4]
for name in s:
if name in schedule_dict:
schedule_dict[name] = schedule_dict[name] + work
else:
schedule_dict[name] = work
if "-" in schedule_dict:
schedule_dict.pop("-")
if len(schedule_dict) == 0:
print("Yes")
elif (max(schedule_dict.values()) - min(schedule_dict.values())) < 13:
print("Yes")
else:
print("No")
weeks = int(input())
schedule_lst = [input().split(" ") for _ in range(weeks*4)]
solution(schedule_lst)
반응형