結果

問題 No.1490 スライムと爆弾
ユーザー convexineqconvexineq
提出日時 2021-04-23 22:34:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 501 ms / 2,000 ms
コード長 1,098 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 123,404 KB
最終ジャッジ日時 2023-09-17 12:39:41
合計ジャッジ時間 8,768 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,348 KB
testcase_01 AC 71 ms
71,456 KB
testcase_02 AC 84 ms
75,808 KB
testcase_03 AC 80 ms
75,804 KB
testcase_04 AC 83 ms
75,924 KB
testcase_05 AC 82 ms
75,900 KB
testcase_06 AC 83 ms
76,008 KB
testcase_07 AC 83 ms
75,960 KB
testcase_08 AC 80 ms
75,808 KB
testcase_09 AC 82 ms
75,960 KB
testcase_10 AC 75 ms
71,328 KB
testcase_11 AC 79 ms
76,056 KB
testcase_12 AC 81 ms
75,912 KB
testcase_13 AC 289 ms
97,512 KB
testcase_14 AC 309 ms
108,204 KB
testcase_15 AC 279 ms
96,924 KB
testcase_16 AC 256 ms
95,284 KB
testcase_17 AC 239 ms
98,952 KB
testcase_18 AC 330 ms
108,304 KB
testcase_19 AC 313 ms
104,308 KB
testcase_20 AC 293 ms
96,836 KB
testcase_21 AC 249 ms
94,700 KB
testcase_22 AC 295 ms
98,784 KB
testcase_23 AC 74 ms
71,288 KB
testcase_24 AC 73 ms
71,388 KB
testcase_25 AC 501 ms
122,772 KB
testcase_26 AC 498 ms
122,912 KB
testcase_27 AC 500 ms
122,668 KB
testcase_28 AC 370 ms
109,584 KB
testcase_29 AC 361 ms
109,220 KB
testcase_30 AC 458 ms
123,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline

h,w,n,m = map(int,readline().split())
tulra = [list(map(int,readline().split())) for _ in range(n)]

b = [[0]*(w+1) for _ in range(h+1)]
for _ in range(m):
    x,y,d,c = map(int,readline().split())
    x -= 1
    y -= 1
    lx = max(0,x-d)
    rx = min(h,x+d+1)
    ly = max(0,y-d)
    ry = min(w,y+d+1)
    b[lx][ly] += c
    b[rx][ly] += -c
    b[lx][ry] += -c
    b[rx][ry] += c

for i in range(h+1):
    for j in range(w):
        b[i][j+1] += b[i][j]
for j in range(w+1):
    for i in range(h):
        b[i+1][j] += b[i][j]

for i in range(h+1):
    for j in range(w):
        b[i][j+1] += b[i][j]
for j in range(w+1):
    for i in range(h):
        b[i+1][j] += b[i][j]

ans = 0
for t,u,l,r,a in tulra:
    t -= 1
    u -= 1
    l -= 1
    r -= 1
    #print(t,u,l,r,a)
    #print((b[t][l] if t and l else 0), (b[u][l-1] if l else 0), (b[t-1][r] if t else 0), b[u][r])
    v = (b[t-1][l-1] if t and l else 0) - (b[u][l-1] if l else 0) - (b[t-1][r] if t else 0) + b[u][r]
    ans += int(a > v)
    #print(v)
print(ans)
0