結果

問題 No.60 魔法少女
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-25 19:19:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 906 ms / 5,000 ms
コード長 618 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 11,972 KB
実行使用メモリ 88,944 KB
最終ジャッジ日時 2023-10-23 19:00:39
合計ジャッジ時間 16,812 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 574 ms
74,140 KB
testcase_01 AC 571 ms
74,144 KB
testcase_02 AC 559 ms
74,144 KB
testcase_03 AC 563 ms
74,136 KB
testcase_04 AC 795 ms
82,148 KB
testcase_05 AC 759 ms
80,896 KB
testcase_06 AC 899 ms
88,944 KB
testcase_07 AC 802 ms
81,564 KB
testcase_08 AC 713 ms
79,688 KB
testcase_09 AC 616 ms
77,316 KB
testcase_10 AC 883 ms
83,888 KB
testcase_11 AC 596 ms
75,480 KB
testcase_12 AC 702 ms
78,068 KB
testcase_13 AC 906 ms
88,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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