[백준] 12788번 제 2회 IUPC는 잘 개최될 수 있을까?

거북이·2023년 3월 9일
0

백준[실버4]

목록 보기
79/91
post-thumbnail

💡문제접근

  • CTP 회원들이 가지고 있는 펜의 수를 내림차순 정렬하면 빌린 회원의 수의 최솟값을 구할 수 있다.

💡코드(메모리 : 31256KB, 시간 : 40ms)

import sys
input = sys.stdin.readline

N = int(input())
M, K = map(int, input().strip().split())
pencil = list(map(int, input().strip().split()))

total = M * K
pencil.sort(reverse=True)
cnt = 0
for i in pencil:
    total -= i
    if total <= 0:
        print(cnt+1)
        break
    cnt += 1

if total > 0:
    print("STRESS")

💡소요시간 : 4m

0개의 댓글