結果

問題 No.1490 スライムと爆弾
ユーザー H3PO4H3PO4
提出日時 2022-08-02 21:32:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 1,086 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 143,768 KB
最終ジャッジ日時 2023-09-30 21:44:33
合計ジャッジ時間 9,351 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,240 KB
testcase_01 AC 71 ms
71,316 KB
testcase_02 AC 81 ms
75,648 KB
testcase_03 AC 80 ms
75,728 KB
testcase_04 AC 80 ms
75,780 KB
testcase_05 AC 80 ms
75,696 KB
testcase_06 AC 80 ms
75,648 KB
testcase_07 AC 81 ms
75,896 KB
testcase_08 AC 80 ms
75,780 KB
testcase_09 AC 81 ms
75,788 KB
testcase_10 AC 73 ms
71,220 KB
testcase_11 AC 80 ms
76,292 KB
testcase_12 AC 83 ms
76,424 KB
testcase_13 AC 290 ms
107,844 KB
testcase_14 AC 275 ms
105,392 KB
testcase_15 AC 249 ms
102,188 KB
testcase_16 AC 252 ms
101,432 KB
testcase_17 AC 204 ms
100,692 KB
testcase_18 AC 312 ms
113,944 KB
testcase_19 AC 296 ms
110,112 KB
testcase_20 AC 259 ms
103,436 KB
testcase_21 AC 219 ms
97,384 KB
testcase_22 AC 276 ms
105,488 KB
testcase_23 AC 72 ms
71,156 KB
testcase_24 AC 71 ms
71,244 KB
testcase_25 AC 324 ms
123,296 KB
testcase_26 AC 324 ms
123,248 KB
testcase_27 AC 333 ms
123,340 KB
testcase_28 AC 352 ms
125,736 KB
testcase_29 AC 339 ms
125,568 KB
testcase_30 AC 439 ms
143,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline

H, W, N, M = map(int, input().split())
slimes = tuple(tuple(map(int, input().split())) for _ in range(N))
bombs = tuple(tuple(map(int, input().split())) for _ in range(M))

table = [[0] * (W + 2) for _ in range(H + 2)]
for x, y, b, c in bombs:
    x -= 1
    y -= 1
    u = max(x - b, 0) + 1
    d = min(x + b + 1, H) + 1
    l = max(y - b, 0) + 1
    r = min(y + b + 1, W) + 1
    table[u][l] += c
    table[u][r] -= c
    table[d][l] -= c
    table[d][r] += c

# 各マスの爆風を計算するimos
for h in range(H + 1):
    for w in range(W + 2):
        table[h + 1][w] += table[h][w]
for h in range(H + 2):
    for w in range(W + 1):
        table[h][w + 1] += table[h][w]

# スライム用のimos
for h in range(H + 1):
    for w in range(W + 2):
        table[h + 1][w] += table[h][w]
for h in range(H + 2):
    for w in range(W + 1):
        table[h][w + 1] += table[h][w]

ans = 0
for t, u, l, r, a in slimes:
    t -= 1
    l -= 1
    if table[t][l] - table[t][r] - table[u][l] + table[u][r] < a:
        ans += 1
print(ans)
0