結果
| 問題 | No.60 魔法少女 | 
| コンテスト | |
| ユーザー |  ゆるく | 
| 提出日時 | 2014-11-10 02:23:49 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2,764 ms / 5,000 ms | 
| コード長 | 984 bytes | 
| コンパイル時間 | 236 ms | 
| コンパイル使用メモリ | 12,800 KB | 
| 実行使用メモリ | 63,488 KB | 
| 最終ジャッジ日時 | 2024-12-31 09:22:22 | 
| 合計ジャッジ時間 | 30,005 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 10 | 
ソースコード
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)
            
            
            
        