๋ฌธ์
https://www.acmicpc.net/problem/18111
ํ์ด
# ๋ฐฑ์ค 18111๋ฒ ๋ฌธ์ - ๋ง์ธํฌ๋ํํธ
import sys
input = sys.stdin.readline
n, m, b = map(int, input().split()) # ์ธ๋ก, ๊ฐ๋ก, ๋ธ๋ก ๊ฐ์
graph = []
graph.append(list(map(int, input().split())) for _ in range(m))
answer = int(1e9)
g_level = 0
for i in range(257):
use_block = 0
take_block = 0
for x in range(n):
for y in range(m):
if graph[x][y] > i:
take_block += graph[x][y] - i
else:
use_block += i - graph[x][y]
if use_block > take_block + b:
continue
count = take_block * 2 + use_block
if count <= answer:
answer = count
g_level = i
print(answer, g_level)
'๐๏ธ Algorithm > ๐ฉ ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ฉ [๋ฐฑ์ค] [Python] [Gold4] 1715๋ฒ_์นด๋ ์ ๋ ฌํ๊ธฐ (0) | 2023.03.28 |
---|---|
๐ฉ [๋ฐฑ์ค] [Python] [Silver1] 11660๋ฒ_๊ตฌ๊ฐ ํฉ ๊ตฌํ๊ธฐ 5 (0) | 2023.03.25 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold5] 11000๋ฒ_๊ฐ์์ค ๋ฐฐ์ (0) | 2023.03.19 |
๐ฉ [๋ฐฑ์ค] [Python] [Silver4] 10825๋ฒ_๊ตญ์์ (0) | 2023.03.18 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold3] 1600๋ฒ_๋ง์ด ๋๊ณ ํ ์์ญ์ด (0) | 2023.03.16 |