結果

問題 No.1490 スライムと爆弾
ユーザー ayaoniayaoni
提出日時 2021-04-23 22:41:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 442 ms / 2,000 ms
コード長 1,252 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 126,304 KB
最終ジャッジ日時 2023-09-17 12:45:34
合計ジャッジ時間 8,197 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,312 KB
testcase_01 AC 75 ms
71,420 KB
testcase_02 AC 84 ms
75,776 KB
testcase_03 AC 82 ms
75,808 KB
testcase_04 AC 84 ms
75,824 KB
testcase_05 AC 84 ms
75,936 KB
testcase_06 AC 84 ms
76,116 KB
testcase_07 AC 81 ms
75,968 KB
testcase_08 AC 82 ms
75,852 KB
testcase_09 AC 81 ms
75,824 KB
testcase_10 AC 75 ms
71,112 KB
testcase_11 AC 82 ms
75,872 KB
testcase_12 AC 85 ms
75,948 KB
testcase_13 AC 288 ms
98,512 KB
testcase_14 AC 309 ms
110,376 KB
testcase_15 AC 264 ms
97,984 KB
testcase_16 AC 270 ms
96,984 KB
testcase_17 AC 212 ms
94,764 KB
testcase_18 AC 339 ms
110,304 KB
testcase_19 AC 314 ms
106,648 KB
testcase_20 AC 283 ms
97,352 KB
testcase_21 AC 232 ms
95,260 KB
testcase_22 AC 294 ms
100,360 KB
testcase_23 AC 73 ms
71,316 KB
testcase_24 AC 74 ms
71,324 KB
testcase_25 AC 353 ms
125,212 KB
testcase_26 AC 353 ms
125,068 KB
testcase_27 AC 349 ms
125,220 KB
testcase_28 AC 334 ms
110,528 KB
testcase_29 AC 324 ms
110,576 KB
testcase_30 AC 442 ms
126,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


H,W,N,M = MI()
slimes = [tuple(MI()) for _ in range(N)]

board = [[0]*(W+2) for _ in range(H+2)]
for _ in range(M):
    X,Y,B,C = MI()
    board[max(1,X-B)][max(1,Y-B)] += C
    board[max(1,X-B)][min(W+1,Y+B+1)] -= C
    board[min(H+1,X+B+1)][max(1,Y-B)] -= C
    board[min(H+1,X+B+1)][min(W+1,Y+B+1)] += C

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

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

ans = 0
for T,U,L,R,A in slimes:
    damage = board[U][R]-board[U][L-1]-board[T-1][R]+board[T-1][L-1]
    if A > damage:
        ans += 1

print(ans)
0