結果

問題 No.60 魔法少女
ユーザー nanaenanae
提出日時 2017-04-14 12:44:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 883 ms / 5,000 ms
コード長 1,069 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 66,544 KB
最終ジャッジ日時 2023-09-25 19:17:12
合計ジャッジ時間 9,029 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 211 ms
16,112 KB
testcase_01 AC 208 ms
16,104 KB
testcase_02 AC 209 ms
16,060 KB
testcase_03 AC 224 ms
23,880 KB
testcase_04 AC 632 ms
50,292 KB
testcase_05 AC 666 ms
65,920 KB
testcase_06 AC 865 ms
65,540 KB
testcase_07 AC 720 ms
59,488 KB
testcase_08 AC 591 ms
57,812 KB
testcase_09 AC 457 ms
50,916 KB
testcase_10 AC 829 ms
65,912 KB
testcase_11 AC 324 ms
51,344 KB
testcase_12 AC 558 ms
59,464 KB
testcase_13 AC 883 ms
66,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def solve():
    N, K = map(int, sys.stdin.readline().split())
    teki = dict()

    for i in range(N):
        x, y, hp = map(int, sys.stdin.readline().split())
        x += 500
        y += 500
        teki[(y, x)] = hp

    kougeki = [[0] * (1000 + 1) for i in range(1000 + 1)]

    for i in range(K):
        ax, ay, w, h, d = map(int, sys.stdin.readline().split())
        ax += 500
        ay += 500
        kougeki[ay][ax] += d
        if ax + w + 1 < 1000 + 1:
            kougeki[ay][ax + w + 1] -= d
        if ay + h + 1 < 1000 + 1:
            kougeki[ay + h + 1][ax] -= d
        if ax + w + 1 < 1000 + 1 and ay + h + 1 < 1000 + 1:
            kougeki[ay + h + 1][ax + w + 1] += d

    for i in range(1000 + 1):
        for j in range(1000):
            kougeki[i][j + 1] += kougeki[i][j]

    for j in range(1000 + 1):
        for i in range(1000):
            kougeki[i + 1][j] += kougeki[i][j]

    ans = 0
    for (y, x), hp in teki.items():
        ans += max(0, hp - kougeki[y][x])

    print(ans)

if __name__ == '__main__':
    solve()
0