結果

問題 No.60 魔法少女
ユーザー lloyzlloyz
提出日時 2023-10-13 22:15:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 284 ms / 5,000 ms
コード長 759 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 86,660 KB
実行使用メモリ 97,340 KB
最終ジャッジ日時 2023-10-13 22:15:37
合計ジャッジ時間 4,926 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
75,800 KB
testcase_01 AC 141 ms
76,032 KB
testcase_02 AC 139 ms
76,240 KB
testcase_03 AC 140 ms
76,136 KB
testcase_04 AC 201 ms
87,372 KB
testcase_05 AC 237 ms
96,796 KB
testcase_06 AC 257 ms
96,664 KB
testcase_07 AC 228 ms
94,180 KB
testcase_08 AC 203 ms
91,924 KB
testcase_09 AC 171 ms
88,060 KB
testcase_10 AC 284 ms
96,828 KB
testcase_11 AC 162 ms
79,776 KB
testcase_12 AC 195 ms
93,848 KB
testcase_13 AC 260 ms
97,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

n, k = map(int, input().split())
M = []
for _ in range(n):
    x, y, h = map(int, input().split())
    x += 500
    y += 500
    M.append((x, y, h))
F = [[0 for _ in range(1002)] for _ in range(1002)]
for _ in range(k):
    sx, sy, ww, hh, d = map(int, input().split())
    sx += 500
    sy += 500
    F[sx][sy] -= d
    F[min(sx + ww + 1, 1001)][sy] += d
    F[sx][min(sy + hh + 1, 1001)] += d
    F[min(sx + ww + 1, 1001)][min(sy + hh + 1, 1001)] -= d
for i in range(1002):
    for j in range(1001):
        F[i][j + 1] += F[i][j]
for j in range(1002):
    for i in range(1001):
        F[i + 1][j] += F[i][j]
ans = 0
for i in range(n):
    x, y, h = M[i]
    d = F[x][y]
    h = max(h + d, 0)
    ans += h
print(ans)
0