https://school.programmers.co.kr/learn/courses/30/lessons/92344
from collections import defaultdict
def solution(board, skill):
answer = 0
space = defaultdict(int)
total = [[0] * (len(board[0]) + 1) for _ in range(len(board) + 1)]
for t, r1, c1, r2, c2, degree in skill:
degree = -degree if t == 1 else degree
total[r1][c1] += degree
total[r1][c2 + 1] += -degree
total[r2 + 1][c1] += -degree
total[r2 + 1][c2 + 1] += degree
for i in range(len(board)):
for j in range(1, len(board[0])):
total[i][j] += total[i][j - 1]
for j in range(len(board)):
for i in range(1, len(board)):
total[i][j] += total[i - 1][j]
for i in range(len(board)):
for j in range(len(board[0])):
if board[i][j] + total[i][j] > 0:
answer += 1
return answer