[프로그래머스] 이모티콘 할인행사

yewon Lee·2023년 7월 20일
0


😎코딩테스트 연습>2023 KAKAO BLIND RECRUITMENT>이모티콘 할인행사


from itertools import product 

def solution(users, emoticons):
    answer = [0,0]
    #중복순열, 완전탐색
    cases = [10, 20, 30, 40]
    for case in product(cases, repeat = len(emoticons)):
        total_pay, plus_num = 0, 0
        for rate, price in users:
            pay = 0
            for i, emoticon in enumerate(emoticons):
                if case[i] >= rate:
                    pay += emoticon * (100 - case[i])//100
                
            if pay >= price:
                plus_num += 1
            else:
                total_pay += pay
        if plus_num > answer[0]:
            answer[0], answer[1] = plus_num, total_pay
        elif plus_num == answer[0] and total_pay > answer[1]:
            answer[1] = total_pay
    
    return answer

참고링크: 이모티콘 할인행사.youtube

profile
시작

1개의 댓글

comment-user-thumbnail
2023년 7월 20일

가치 있는 정보 공유해주셔서 감사합니다.

답글 달기