Skip to content

Commit

Permalink
2024-03-03 solved
Browse files Browse the repository at this point in the history
  • Loading branch information
alstjr7437 committed Mar 3, 2024
1 parent dc33d65 commit 29b40b8
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import sys
input = sys.stdin.readline

n, m, b = map(int, input().split())

ground = []
for i in range(n):
ground.append(list(map(int, input().split())))

answer = int(1e9)
idx = 0

for floor in range(257):
# task1 -> ๋ธ”๋ก์„ ๋นผ๋Š” ๊ฒƒ
# task2 -> ๋ธ”๋ก์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ
task1 = 0
task2 = 0
for x in range(n):
for y in range(m):
# ๋ธ”๋ก์ด ์ธต์ˆ˜๋ณด๋‹ค ํฌ๋ฉด
if ground[x][y] > floor:
task1 += ground[x][y] - floor
# ๋ธ”๋ก์ด ์ธต์ˆ˜๋ณด๋‹ค ์ž‘์œผ๋ฉด
else:
task2 += floor - ground[x][y]

# ๋ธ”๋ก์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ > ๊ฐ€์ง€๊ณ  ์žˆ๋˜ ๋ธ”๋ก์˜ ํ•ฉ + ๋ธ”๋ก์„ ๋นผ์„œ ๊ฐ€์ ธ์˜จ ๊ฒƒ์ด๋ฉด
# ๋ธ”๋ก์„ ๋” ๋ชป๊ฐ€์ ธ์˜ค๋Š”๋ฐ ๊ฐ€์ ธ์™”์œผ๋ฏ€๋กœ ๋‹ค์‹œ ์ฒ˜์Œ์œผ๋กœ
if task2 > task1 + b:
continue
# ์‹œ๊ฐ„ ์ดˆ๋ฅผ ๊ตฌํ•˜๊ณ  ์ตœ์ € ์‹œ๊ฐ„๊ณผ ๋น„๊ต
count = task1 * 2 + task2
if count <= answer:
answer = count
idx = floor

print(answer, idx)

0 comments on commit 29b40b8

Please sign in to comment.