結果

問題 No.60 魔法少女
ユーザー H3PO4
提出日時 2020-04-23 10:35:17
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,400 ms / 5,000 ms
コード長 701 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 83,232 KB
最終ジャッジ日時 2024-10-13 07:35:24
合計ジャッジ時間 14,856 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

input = sys.stdin.readline

N, K = map(int, input().split())

enemies = np.zeros((1002, 1002), dtype=int)
damages = np.zeros((1002, 1002), dtype=int)
for _ in range(N):
    x, y, hp = map(int, input().split())
    enemies[y + 500][x + 500] = hp

for _ in range(K):
    ax, ay, w, h, d = map(int, input().split())
    ax += 500
    ay += 500
    axw = min(ax + w + 1, 1001)
    ayh = min(ay + h + 1, 1001)
    damages[ay][ax] += d
    damages[ayh][ax] -= d
    damages[ay][axw] -= d
    damages[ayh][axw] += d

np.cumsum(damages, axis=0, out=damages)
np.cumsum(damages, axis=1, out=damages)
print(np.sum(np.maximum(enemies - damages, np.zeros_like(enemies, dtype=int))))
0