BOJ - 14719 - 빗물
Updated:
import sys
def solution():
H, W = map(int, sys.stdin.readline().split())
block = list(map(int, sys.stdin.readline().split()))
blockMap = [[0 for _ in range(501)] for _ in range(501)]
for i in range(W):
for j in range(block[i]):
blockMap[j][i] = 1
ret = 0
for i in range(H):
flag = False
temp = 0
for j in range(W):
if flag:
if blockMap[i][j] == 1:
ret += temp
temp = 0
else:
temp += 1
else:
if blockMap[i][j] == 1:
flag = True
print(ret)
solution()
https://www.acmicpc.net/problem/14719
Leave a comment