結果

問題 No.1490 スライムと爆弾
ユーザー roarisroaris
提出日時 2021-04-23 22:49:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 534 ms / 2,000 ms
コード長 1,001 bytes
コンパイル時間 694 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 165,968 KB
最終ジャッジ日時 2023-09-17 12:50:34
合計ジャッジ時間 9,106 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,320 KB
testcase_01 AC 75 ms
71,396 KB
testcase_02 AC 83 ms
76,044 KB
testcase_03 AC 82 ms
75,852 KB
testcase_04 AC 83 ms
75,960 KB
testcase_05 AC 80 ms
75,920 KB
testcase_06 AC 82 ms
76,228 KB
testcase_07 AC 82 ms
75,864 KB
testcase_08 AC 80 ms
75,820 KB
testcase_09 AC 81 ms
76,068 KB
testcase_10 AC 78 ms
71,540 KB
testcase_11 AC 79 ms
75,712 KB
testcase_12 AC 81 ms
75,960 KB
testcase_13 AC 321 ms
113,896 KB
testcase_14 AC 334 ms
120,692 KB
testcase_15 AC 292 ms
101,140 KB
testcase_16 AC 281 ms
103,220 KB
testcase_17 AC 253 ms
116,848 KB
testcase_18 AC 364 ms
129,564 KB
testcase_19 AC 340 ms
118,036 KB
testcase_20 AC 315 ms
102,276 KB
testcase_21 AC 265 ms
98,704 KB
testcase_22 AC 316 ms
108,584 KB
testcase_23 AC 73 ms
71,360 KB
testcase_24 AC 73 ms
71,524 KB
testcase_25 AC 417 ms
142,724 KB
testcase_26 AC 412 ms
142,676 KB
testcase_27 AC 411 ms
142,984 KB
testcase_28 AC 439 ms
143,684 KB
testcase_29 AC 428 ms
150,680 KB
testcase_30 AC 534 ms
165,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

H, W, N, M = map(int, input().split())
TULRA = [tuple(map(int, input().split())) for _ in range(N)]
XYBC = [tuple(map(int, input().split())) for _ in range(M)]
damage = [[0]*(W+1) for _ in range(H+1)]

for X, Y, B, C in XYBC:
    X -= 1
    Y -= 1
    sx = max(0, X-B)
    gx = min(H-1, X+B)
    sy = max(0, Y-B)
    gy = min(W-1, Y+B)
    damage[sx][sy] += C
    damage[sx][gy+1] -= C
    damage[gx+1][sy] -= C
    damage[gx+1][gy+1] += C

for i in range(H+1):
    for j in range(1, W+1):
        damage[i][j] += damage[i][j-1]

for i in range(W+1):
    for j in range(1, H+1):
        damage[j][i] += damage[j-1][i]

acc = [[0]*(W+1) for _ in range(H+1)]

for i in range(H):
    for j in range(W):
        acc[i+1][j+1] = acc[i+1][j]+acc[i][j+1]-acc[i][j]+damage[i][j]

ans = 0

for T, U, L, R, A in TULRA:
    T -= 1
    U -= 1
    L -= 1
    R -= 1
    dama = acc[U+1][R+1]-acc[U+1][L]-acc[T][R+1]+acc[T][L]
    
    if A-dama>0:
        ans += 1

print(ans)
0