[백준] 12034번 김인천씨의 식료품 가게(Large)

거북이·2023년 1월 1일
0

백준[실버5]

목록 보기
8/114
post-thumbnail

💡문제접근

입력받은 가격들을 내림차순으로 정렬하고 pop(0)을 이용해서 맨 앞에 있는 원소를 가져온다.
해당 원소의 25% 할인된 가격이 가격 리스트에 존재하는 경우 할인가격을 할인가격 리스트에 저장하고 해당 할인가격을 입력받은 가격 리스트에서 제거한다.

💡코드

T = int(input())
num = 1
for _ in range(T):
	# discount_price_lst = 할인가격이 저장되는 리스트
    discount_price_lst = []
    N = int(input())
    # price_lst = 입력받은 가격이 저장되는 리스트
    price_lst= sorted(list(map(int, input().split())), reverse=True)
    while True:
        if price_lst == []:
            break
        else:
            price = price_lst.pop(0)
            if price * 0.75 in price_lst:
                discount_price_lst.append(int(price * 0.75))
                price_lst.remove(int(price * 0.75))
    discount_price_lst.sort()
    print("Case #" + str(num) + ":", *discount_price_lst)
    num += 1

0개의 댓글