結果

問題 No.60 魔法少女
ユーザー simamumu
提出日時 2018-10-03 12:19:34
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 2,331 ms / 5,000 ms
コード長 882 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 96,256 KB
最終ジャッジ日時 2024-10-12 10:17:08
合計ジャッジ時間 23,169 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,K = inpl()
W,H = 1010,1010
monster = [inpl() for i in range(N)]
attack = [inpl() for i in range(K)]
MAP = [[0]*W for i in range(H)]

for x,y,w,h,D in attack:
    x += W//2
    y += H//2
    MAP[y][x] += D
    MAP[y][min(W-1,x+w+1)] -= D
    MAP[min(H-1,y+h+1)][x] -= D
    MAP[min(H-1,y+h+1)][min(W-1,x+w+1)] += D

for y in range(H):
    tmp = 0
    for x in range(W):
        tmp += MAP[y][x]
        MAP[y][x] = tmp

for x in range(H):
    tmp = 0
    for y in range(W):
        tmp += MAP[y][x]
        MAP[y][x] = tmp

ans = 0
for x,y,hp in monster:
    ans += max(hp - MAP[y+H//2][x+W//2],0)
print(ans)
0