본문 바로가기

Programming [Python]/백준 알고리즘 솔루션

#332 백준 파이썬 [13304] 방 배정

https://www.acmicpc.net/problem/13304

 

PYTHON CODE

import math

N, K = map(int, input().split())
student = [0, 0, 0, 0, 0] #12남여 / 34여 / 34남 / 56여 / 56남

for _ in range(N):
    S, Y = map(int, input().split())
    if Y == 1 or Y == 2:
        student[0] += 1
    elif S == 0 and (Y == 3 or Y == 4):
        student[1] += 1
    elif S == 1 and (Y == 3 or Y == 4):
        student[2] += 1
    elif S == 0 and (Y == 5 or Y == 6):
        student[3] += 1
    else:
        student[4] += 1
        
room = 0
for i in student:
    room += math.ceil(i / K)
print(room)