結果

問題 No.60 魔法少女
ユーザー nanaenanae
提出日時 2017-04-14 12:42:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,067 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 10,972 KB
実行使用メモリ 66,684 KB
最終ジャッジ日時 2023-09-25 19:16:50
合計ジャッジ時間 9,230 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 212 ms
16,116 KB
testcase_01 AC 210 ms
16,076 KB
testcase_02 AC 211 ms
16,100 KB
testcase_03 AC 226 ms
24,020 KB
testcase_04 AC 615 ms
50,424 KB
testcase_05 AC 654 ms
65,916 KB
testcase_06 AC 860 ms
65,676 KB
testcase_07 WA -
testcase_08 AC 578 ms
57,616 KB
testcase_09 AC 456 ms
50,928 KB
testcase_10 AC 829 ms
65,784 KB
testcase_11 AC 330 ms
51,240 KB
testcase_12 AC 564 ms
59,456 KB
testcase_13 AC 871 ms
66,684 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