반응형
https://www.acmicpc.net/problem/13458
13458번: 시험 감독
첫째 줄에 시험장의 개수 N(1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 각 시험장에 있는 응시자의 수 Ai (1 ≤ Ai ≤ 1,000,000)가 주어진다. 셋째 줄에는 B와 C가 주어진다. (1 ≤ B, C ≤ 1,000,000)
www.acmicpc.net


삼성A형 기출문제는 지금까지 거의 다 Brute Force + DFS / BFS 형태였는데, 별다른 고민없이 그냥 풀었던 문제.
모든 시험방에는 최소 한 명의 총감독관이 필요하고, (각 방에 남은 응시자 수 / 부감독관 1인당 처리할 수 있는 사람 수) 값을 소수점 이하 올림하면 각 방에 들어갈 수 있는 부감독관의 최소 숫자가 나온다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import math | |
n = int(sys.stdin.readline()) | |
arr = list(map(int, sys.stdin.readline().split())) | |
b, c = map(int, sys.stdin.readline().split()) | |
# 어쨌든 총감독 한 명씩은 필요함 | |
result = len(arr) | |
# 총감독 한 명으로 부족한 방 | |
rest = [i - b for i in arr if i - b > 0] | |
# 보조감독은 얼마나 필요한지 | |
rest2 = [math.ceil(i / c) for i in rest] | |
result += sum(rest2) | |
print(result) |
반응형
'프로그래밍 > 코딩테스트 문제풀이' 카테고리의 다른 글
[Python] 프로그래머스. 숫자 블록 (Level 4) (0) | 2019.11.16 |
---|---|
[Python] 프로그래머스. 순위 (Level 3) (0) | 2019.11.15 |
[Python] 프로그래머스. 디스크 컨트롤러 (Level 3) (0) | 2019.11.13 |
[Python] 백준 10775. 공항 (0) | 2019.11.12 |
[Python] 백준 14889. 스타트와 링크 (0) | 2019.11.11 |