SMALL
dictionary를 사용하여 해당 유효기간의 달 수를 저장한 후,
오늘을 모두 날로 환산하고,
지금의 date와 비교하고 아직 유효한 경우만 answer에 append하여 문제를 해결했다.
from collections import defaultdict
def solution(today, terms, privacies):
dict = {}
for i in terms:
type, valMonth = i.split(" ")
dict[type] = valMonth
cnt = 0
answer = []
todayDate = today.split(".")
todayTotalDays = (int(todayDate[0]) * 12 *28) + (int(todayDate[1]) * 28) + int(todayDate[2])
for i in privacies:
cnt += 1
earnDate, assignType = i.split(" ")
y, m, d = earnDate.split(".")
thisTotalDays = (int(y) * 12 *28) + (int(m) * 28) + int(d) + (int(dict[assignType]) * 28)
if (thisTotalDays <= todayTotalDays):
answer.append(cnt)
print(answer)
return answer
LIST
'BOJ' 카테고리의 다른 글
BOJ 백준 C++ 1759번 암호만들기 (1) | 2024.02.13 |
---|---|
2022 KAKAO TECH INTERNSHIP : 성격 유형 검사하기 (2) | 2023.11.13 |
BOJ 1157번 단어공부 파이썬 (0) | 2022.03.17 |
백준 9012번 괄호 자바 풀이 (0) | 2022.01.19 |
BOJ 17608번 막대기 (0) | 2022.01.13 |