結果

問題 No.60 魔法少女
ユーザー ゆるくゆるく
提出日時 2014-11-10 02:23:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,406 ms / 5,000 ms
コード長 984 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 61,984 KB
最終ジャッジ日時 2023-08-30 03:01:47
合計ジャッジ時間 26,733 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,110 ms
27,540 KB
testcase_01 AC 1,106 ms
27,444 KB
testcase_02 AC 1,101 ms
27,444 KB
testcase_03 AC 1,159 ms
35,268 KB
testcase_04 AC 1,953 ms
59,464 KB
testcase_05 AC 1,941 ms
61,920 KB
testcase_06 AC 2,358 ms
61,812 KB
testcase_07 AC 2,104 ms
61,152 KB
testcase_08 AC 1,842 ms
60,612 KB
testcase_09 AC 1,593 ms
59,388 KB
testcase_10 AC 2,308 ms
61,984 KB
testcase_11 AC 1,333 ms
58,916 KB
testcase_12 AC 1,752 ms
61,156 KB
testcase_13 AC 2,406 ms
61,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy


n, k = map(int, input().split())
M = 500
SIZE = 1002
f = [[0 for _ in range(SIZE + 1)] for _ in range(SIZE + 1)]
im = [[0 for _ in range(SIZE + 1)] for _ in range(SIZE + 1)]


for _ in range(n):
  x, y, h = map(int, input().split())
  f[y + M][x + M] = h

for _ in range(k):
  ax, ay, w, h, d = map(int, input().split())
  mx = min(ax + M + w + 1, SIZE)
  my = min(ay + M + h + 1, SIZE)

  im[ay + M][ax + M] += d
  im[my][ax + M] -= d
  im[ay + M][mx] -= d
  im[my][mx] += d

for y in range(SIZE + 1):
  for x in range(SIZE):
    im[y][x + 1] += im[y][x]

for x in range(SIZE + 1):
  for y in range(SIZE):
    im[y + 1][x] += im[y][x]

ans = 0
for x in range(SIZE + 1):
  for y in range(SIZE + 1):
    ans += max(f[y][x] - im[y][x], 0)

print(ans)
0