[백준/파이썬] 16427번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 16427번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
Your Chief Judge needs help! He needs to set the time limit for a problem in the problem set. He has n solutions written by his judges. He knows how long each runs in the contest environment, in milliseconds. He wants to set the time limit to be at least s times the slowest solution from his judges, but as small as possible, and he wants it to be an integral number of seconds. Can you help him?
입력 요약
Each input will consist of a single test case. Note that your program may be run multiple times on different inputs.
Each test case will begin with a line containing two space-separated integers n (1 ≤ n ≤ 100) and s (1 ≤ s ≤ 20), where n is the number of solutions from judges, …
출력 요약
Output a single integer, which is the time limit to set for this problem. It should be in seconds, and the smallest time that is at least s times the slowest judge’s solution.
코드
import math
n,s=map(int,input().split())
print(math.ceil(max(map(int,input().split()))*s/1000))
설명
핵심은 구현 관점에서 Your Chief Judge needs help! He needs to set the time limit for a problem in the problem set. He has n solutions written by his judges. …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기