Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 완전탐색
- Stack
- PCCP
- Vite
- Algorithm
- Jest
- modbus
- 점화식
- Two Pointer
- configfile
- 파이썬
- queue
- pymodbus
- monorepo
- algorhtim
- typescript
- pnpm
- InfluxDB
- React
- algorighm
- python
- 알고리즘
- 프로그래머스
- telegraf
- Server monitoring
- javascript
- 슬라이딩 윈도우
- frontend
- 코딩테스트 연습
- 스택/큐
Archives
- Today
- Total
DM Log
[2023 KAKAO BLIND RECRUITMENT] 이모티콘 할인 행사 - Python 본문
문제링크 - https://school.programmers.co.kr/learn/courses/30/lessons/150368
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
[문제 간단 요약]
1. 가입자 수와 매출액을 최대로 하는 값을 구하는 구현 문제
2. 가입자 수를 우선 조건으로 하고 매출액을 다음 조건으로 값을 구해야함
[문제 해결 방안]
1. 할인에 해당하는 배열 조합을 이모티콘의 수만큼 만들기
2. 이모티콘이 할인 가능한 모든 금액을 구하고 조건에 맞는 가입자 수와 매출액을 하여 문제 해결
[문제 해결 코드 - Python]
from itertools import product
def solution(users, emoticons):
discount_rates = [10, 20, 30, 40]
max_result = [0, 0]
for discount_rate in product(discount_rates, repeat=len(emoticons)):
pub = 0
profit = 0
for user in users:
rate = user[0]
max_price = user[1]
discount_price = 0
for discount, emoticon in zip(discount_rate, emoticons):
if rate <= discount:
discount_price += emoticon * (100-discount) //100
if discount_price >= max_price:
pub += 1
else:
profit += discount_price
if max_result[0] < pub:
max_result[0] = pub
max_result[1] = profit
elif max_result[0] == pub:
max_result[1] = max(max_result[1], profit)
return max_result
'알고리즘 > 프로그래머스' 카테고리의 다른 글
[연습문제] 인사고과 - Python/JavaScript (1) | 2025.01.21 |
---|---|
[코딩테스트 연습] 혼자서 하는 틱택토 - Python (1) | 2025.01.12 |
[PCCP 기출문제] 2번 / 석유 시추 - Python/JavaScript (0) | 2025.01.08 |
[PCCP 기출문제] 1번 / 붕대 감기 - Python/JavaScript (1) | 2025.01.06 |
[PCCP 기출문제] 2번 / 퍼즐 게임 챌린지 - Python/JavaScript (0) | 2025.01.05 |