문제링크 : https://school.programmers.co.kr/learn/courses/30/lessons/92344
def solution(board, skill):
n = len(board)
m = len(board[0])
def stack_point(x1,y1,x2,y2,d):
acc_board[x1][y1] += d
acc_board[x1][y2+1] -= d
acc_board[x2+1][y1] -= d
acc_board[x2+1][y2+1] += d
acc_board = [[0 for _ in range(1001)] for _ in range(1001)]
for t,x1,y1,x2,y2,d in skill:
if t == 1:
stack_point(x1,y1,x2,y2,-d)
else:
stack_point(x1,y1,x2,y2,d)
for i in range(n):
for j in range(1,m):
acc_board[i][j] = acc_board[i][j-1] + acc_board[i][j]
for j in range(m):
for i in range(1,n):
acc_board[i][j] = acc_board[i-1][j] + acc_board[i][j]
ans = 0
for i in range(n):
for j in range(m):
if board[i][j] + acc_board[i][j] >= 1:
ans += 1
return ans