본문 바로가기
Algorithm/BOJ

[BOJ] 18111 | 마인크래프트

by 밤초록 2022. 2. 8.
18111 | 마인크래프트
https://www.acmicpc.net/problem/18111

 

 

 

 

작성 코드

 

import sys
n, m, b = map(int, sys.stdin.readline().split())

mine = []

for _ in range(n):
    mine += map(int, sys.stdin.readline().split()) 

times = []
mine_maxs = []

mine_max = max(mine)

for _ in range(256):
    time = 0
    need = 0
    over = 0
    for i in mine:
        if mine_max > i:
            need += mine_max - i
        elif mine_max < i:
            over += i - mine_max

    if need > over + b:
        mine_max -= 1

    else:
        time += 2*over + need

        times.append(time)
        mine_maxs.append(mine_max)
        mine_max -= 1

        

print(min(times), mine_maxs[times.index(min(times))] )

 

 

반응형

'Algorithm > BOJ' 카테고리의 다른 글

[BOJ] 2839 | 설탕배달  (0) 2022.02.11
[BOJ] 11659 | 구간 합 구하기 4  (0) 2022.02.09
[BOJ] 17298 | 오큰수  (0) 2022.02.04
[BOJ] 12871 | 무한 문자열  (0) 2022.01.27
[BOJ][#] 1002 | 터렛  (0) 2022.01.25

댓글