結果

問題 No.60 魔法少女
ユーザー brthyyjpbrthyyjp
提出日時 2021-07-27 02:04:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 264 ms / 5,000 ms
コード長 1,087 bytes
コンパイル時間 1,073 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 112,256 KB
最終ジャッジ日時 2023-09-29 23:46:26
合計ジャッジ時間 4,395 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
90,956 KB
testcase_01 AC 140 ms
90,780 KB
testcase_02 AC 147 ms
90,864 KB
testcase_03 AC 146 ms
90,912 KB
testcase_04 AC 220 ms
100,216 KB
testcase_05 AC 228 ms
109,724 KB
testcase_06 AC 262 ms
110,824 KB
testcase_07 AC 232 ms
106,908 KB
testcase_08 AC 216 ms
104,840 KB
testcase_09 AC 182 ms
99,336 KB
testcase_10 AC 249 ms
110,928 KB
testcase_11 AC 150 ms
84,476 KB
testcase_12 AC 208 ms
105,920 KB
testcase_13 AC 264 ms
112,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0