結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-07-28 19:30:47 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,543 ms / 5,000 ms |
| コード長 | 1,317 bytes |
| コンパイル時間 | 125 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 77,184 KB |
| 最終ジャッジ日時 | 2024-07-17 13:23:15 |
| 合計ジャッジ時間 | 14,702 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 |
ソースコード
class Imos2D():
def __init__(self, W, H):
self.W = W
self.H = H
self.data = [[0] * (W + 1) for w in range(H + 1)]
def range_add(self, x1, y1, w, h, d):
x2 = min(x1 + w + 1, self.W)
y2 = min(y1 + h + 1, self.H)
data = self.data
data[y1][x1] += d
data[y1][x2] -= d
data[y2][x1] -= d
data[y2][x2] += d
def read_all(self):
decoded = [[0] * self.W for h in range(self.H)]
current_row = [0] * self.W
for y, row in enumerate(self.data[:-1]):
prev_row = current_row
current_row = decoded[y]
cum = 0
for x, val in enumerate(row[:-1]):
cum += val
current_row[x] = cum + prev_row[x]
return decoded
X = 500
Y = 500
N, K = map(int, input().split())
HP = [[0] * (2 * Y + 1) for w in range(2 * X + 1)]
for n in range(N):
x, y, hp = map(int, input().split())
HP[y + Y][x + X] = hp
attacks = Imos2D(X * 2 + 1, Y * 2 + 1)
for k in range(K):
ax, ay, w, h, d = map(int, input().split())
attacks.range_add(ax + X, ay + Y, w, h, d)
damage = attacks.read_all()
cumsum = 0
for row_d, row_hp in zip(damage, HP):
for d, hp in zip(row_d, row_hp):
if hp and hp > d:
cumsum += hp - d
print(cumsum)