結果

問題 No.60 魔法少女
コンテスト
ユーザー tktk_snsn
提出日時 2020-12-25 19:19:42
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 631 ms / 5,000 ms
+ 774µs
コード長 618 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 57 ms
コンパイル使用メモリ 14,848 KB
実行使用メモリ 80,796 KB
最終ジャッジ日時 2026-10-15 05:56:40
合計ジャッジ時間 11,244 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import numpy as np
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
U = 1000

N, K = map(int, input().split())
xyh = np.array([input().split() for _ in range(N)], dtype=np.int64)
x, y, h, w, d = np.array([input().split() for _ in range(K)], dtype=np.int64).T
x += U
y += U

G = np.zeros((2*U+2, 2*U+2), dtype=np.int64)
np.add.at(G, (x, y), d)
np.add.at(G, (x + h + 1, y), -d)
np.add.at(G, (x, y + w + 1), -d)
np.add.at(G, (x + h + 1, y + w + 1), d)
np.cumsum(G, axis=0, out=G)
np.cumsum(G, axis=1, out=G)

x, y, h = xyh.T
x += U
y += U
rest = h - G[x, y]
rest[rest < 0] = 0
print(rest.sum())
0