結果

問題 No.60 魔法少女
ユーザー H3PO4H3PO4
提出日時 2020-04-23 10:32:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,417 ms / 5,000 ms
コード長 757 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 85,988 KB
最終ジャッジ日時 2024-04-21 08:39:27
合計ジャッジ時間 18,112 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 721 ms
83,404 KB
testcase_01 AC 722 ms
82,772 KB
testcase_02 AC 719 ms
82,776 KB
testcase_03 AC 728 ms
83,076 KB
testcase_04 AC 1,127 ms
83,936 KB
testcase_05 AC 1,080 ms
85,000 KB
testcase_06 AC 1,405 ms
85,680 KB
testcase_07 AC 1,211 ms
85,988 KB
testcase_08 AC 1,019 ms
85,216 KB
testcase_09 AC 846 ms
83,532 KB
testcase_10 AC 1,347 ms
84,928 KB
testcase_11 AC 766 ms
83,084 KB
testcase_12 AC 950 ms
83,756 KB
testcase_13 AC 1,417 ms
85,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

input = sys.stdin.readline

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

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

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
damages = np.array(damages)

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