結果
問題 | No.60 魔法少女 |
ユーザー |
![]() |
提出日時 | 2021-07-27 02:04:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 259 ms / 5,000 ms |
コード長 | 1,087 bytes |
コンパイル時間 | 385 ms |
コンパイル使用メモリ | 82,020 KB |
実行使用メモリ | 110,568 KB |
最終ジャッジ日時 | 2024-07-22 17:42:41 |
合計ジャッジ時間 | 4,557 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
ソースコード
class imos2D: def __init__(self, h, w): self.h = h self.w = w self.imos = [[0]*(w+1) for i in range(h+1)] def add(self, y0, x0, y1, x1, v): # add [(y0,x0), (y1,x1)] self.imos[y0][x0] += v self.imos[y1+1][x1+1] += v self.imos[y0][x1+1] -= v self.imos[y1+1][x0] -= v def calc(self): for y in range(self.h+1): for x in range(self.w): self.imos[y][x+1] += self.imos[y][x] for x in range(self.w+1): for y in range(self.h): self.imos[y+1][x] += self.imos[y][x] import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n, k = map(int, input().split()) XY = [] for i in range(n): x, y, h = map(int, input().split()) x += 500 y += 500 XY.append((x, y, h)) imos = imos2D(1550, 1550) for i in range(k): ax, ay, w, h, d = map(int, input().split()) ax += 500 ay += 500 imos.add(ax, ay, ax+w, ay+h, d) imos.calc() ans = 0 for x, y, h in XY: ans += max(0, h-imos.imos[x][y]) print(ans)