結果

問題 No.60 魔法少女
ユーザー yuki2006yuki2006
提出日時 2014-11-09 21:15:22
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,975 ms / 5,000 ms
コード長 1,077 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 6,500 KB
実行使用メモリ 50,048 KB
最終ジャッジ日時 2023-08-30 02:49:10
合計ジャッジ時間 21,362 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 854 ms
23,832 KB
testcase_01 AC 867 ms
23,656 KB
testcase_02 AC 856 ms
23,688 KB
testcase_03 AC 866 ms
29,660 KB
testcase_04 AC 1,546 ms
48,276 KB
testcase_05 AC 1,554 ms
50,048 KB
testcase_06 AC 1,961 ms
50,032 KB
testcase_07 AC 1,701 ms
49,292 KB
testcase_08 AC 1,456 ms
49,128 KB
testcase_09 AC 1,215 ms
48,116 KB
testcase_10 AC 1,900 ms
49,980 KB
testcase_11 AC 1,000 ms
47,728 KB
testcase_12 AC 1,405 ms
49,416 KB
testcase_13 AC 1,975 ms
50,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
N, K = map(int, raw_input().split())

SIZE = 1000 + 2
GETA = 500
field = [[0 for i in xrange(SIZE + 1)] for i in xrange(SIZE + 1)]
imosField = [[0 for i in xrange(SIZE + 1)] for i in xrange(SIZE + 1)]

for _ in xrange(N):
    X, Y, H = map(int, raw_input().split())
    field[X + GETA][Y + GETA] = H

for _ in xrange(K):
    AX, AY, W, H, D = map(int, raw_input().split())
    MX = min(AX + GETA + W + 1, SIZE)
    MY = min(AY + GETA + H + 1, SIZE)

    imosField[AX + GETA][AY + GETA] += D
    imosField[MX][AY + GETA] -= D
    imosField[AX + GETA][MY] -= D
    imosField[MX][MY] += D

# X方向に累積和で算出
for y in xrange(SIZE + 1):
    for x in xrange(SIZE):
        imosField[x + 1][y] += imosField[x][y]

# Y方向に累積和で算出
for x in xrange(SIZE + 1):
    for y in xrange(SIZE):
        imosField[x][y + 1] += imosField[x][y]

# ダメージを与える
total = 0
for x in xrange(SIZE + 1):
    for y in xrange(SIZE + 1):
        total += max(field[x][y] - imosField[x][y], 0)

print total
0