結果

問題 No.60 魔法少女
ユーザー むらためむらため
提出日時 2017-08-16 01:22:31
言語 Nim
(2.0.2)
結果
AC  
実行時間 101 ms / 5,000 ms
コード長 959 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 66,184 KB
実行使用メモリ 18,820 KB
最終ジャッジ日時 2023-09-12 14:37:43
合計ジャッジ時間 4,016 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
12,980 KB
testcase_01 AC 21 ms
12,948 KB
testcase_02 AC 21 ms
12,980 KB
testcase_03 AC 21 ms
17,052 KB
testcase_04 AC 62 ms
18,736 KB
testcase_05 AC 67 ms
18,820 KB
testcase_06 AC 97 ms
18,708 KB
testcase_07 AC 76 ms
18,784 KB
testcase_08 AC 55 ms
18,764 KB
testcase_09 AC 35 ms
18,708 KB
testcase_10 AC 90 ms
18,736 KB
testcase_11 AC 28 ms
18,752 KB
testcase_12 AC 52 ms
18,812 KB
testcase_13 AC 101 ms
18,784 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'math' [UnusedImport]

ソースコード

diff #

import math
template times*(n:int,body:untyped): untyped = (for _ in 0..<n: body)
proc scanf(frmt: cstring):void {.varargs, importc:"scanf",header: "<stdio.h>" .}

var field: array[1001, array[1001, int]]
var damage: array[1002, array[1002, int]]
var N,K : int32
scanf("%d %d", addr N, addr K)
N.times:
  var x,y,h: int32
  scanf("%d %d %d", addr x, addr y, addr h )
  field[y + 500][x + 500] = h
K.times:
  var x1,y1,w,h,d: int32
  scanf("%d %d %d %d %d", addr x1, addr y1, addr w , addr h , addr d )
  x1 += 500
  y1 += 500
  let
    x2 = 1001.min(x1 + w + 1)
    y2 = 1001.min(y1 + h + 1)
  damage[y1][x1] += d
  damage[y1][x2] -= d
  damage[y2][x1] -= d
  damage[y2][x2] += d
for x in 0..1000:
  for y in 1..1000:
    damage[x][y] +=  damage[x][y - 1]
for x in 1..1000:
  for y in 0..1000:
    damage[x][y] += damage[x - 1][y]
var R = 0
for x in 0..1000:
  for y in 0..1000:
    if field[x][y] > damage[x][y]:
      R += field[x][y] - damage[x][y]
echo R
0