結果

問題 No.60 魔法少女
ユーザー szkhtsszkhts
提出日時 2024-04-21 08:08:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,057 ms / 5,000 ms
コード長 762 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 61,056 KB
最終ジャッジ日時 2024-04-21 08:09:07
合計ジャッジ時間 19,472 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 585 ms
19,456 KB
testcase_01 AC 599 ms
19,328 KB
testcase_02 AC 585 ms
19,584 KB
testcase_03 AC 593 ms
27,136 KB
testcase_04 AC 1,391 ms
52,608 KB
testcase_05 AC 1,487 ms
60,544 KB
testcase_06 AC 1,958 ms
60,544 KB
testcase_07 AC 1,613 ms
58,112 KB
testcase_08 AC 1,318 ms
56,704 KB
testcase_09 AC 1,006 ms
52,992 KB
testcase_10 AC 1,847 ms
60,544 KB
testcase_11 AC 804 ms
52,864 KB
testcase_12 AC 1,304 ms
57,984 KB
testcase_13 AC 2,057 ms
61,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

dp = [[0 for i in range(1010)] for j in range(1010)]
n, k = map(int, input().split())

x = [0] * n
y = [0] * n
hp = [0] * n
for i in range(n):
    xi, yi, hpi = map(int, input().split())
    x[i] = xi + 501
    y[i] = yi + 501
    hp[i] = hpi

for i in range(k):
    ax, ay, w, h, d = map(int, input().split())
    ax += 501
    ay += 501
    bx = min(1005, ax + w + 1)
    by = min(1005, ay + h + 1)
    dp[ay][ax] += d
    dp[ay][bx] -= d
    dp[by][ax] -= d
    dp[by][bx] += d
    
for i in range(1, 1006):
    for j in range(1, 1006):
        dp[i][j] += dp[i][j - 1]
        
for j in range(1, 1006):
    for i in range(1, 1006):
        dp[i][j] += dp[i - 1][j]
        
ans = 0
for i in range(n):
    ans += max(0, hp[i] - dp[y[i]][x[i]])
    
print(ans)
0