結果
問題 | No.60 魔法少女 |
ユーザー | letrangerjp |
提出日時 | 2017-06-18 00:35:49 |
言語 | Ruby (3.3.0) |
結果 |
AC
|
実行時間 | 916 ms / 5,000 ms |
コード長 | 736 bytes |
コンパイル時間 | 51 ms |
コンパイル使用メモリ | 11,904 KB |
実行使用メモリ | 43,776 KB |
最終ジャッジ日時 | 2024-04-08 20:52:25 |
合計ジャッジ時間 | 9,075 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 317 ms
24,192 KB |
testcase_01 | AC | 319 ms
24,192 KB |
testcase_02 | AC | 317 ms
24,192 KB |
testcase_03 | AC | 317 ms
24,192 KB |
testcase_04 | AC | 636 ms
31,872 KB |
testcase_05 | AC | 658 ms
35,456 KB |
testcase_06 | AC | 916 ms
39,168 KB |
testcase_07 | AC | 715 ms
37,504 KB |
testcase_08 | AC | 564 ms
31,872 KB |
testcase_09 | AC | 423 ms
26,880 KB |
testcase_10 | AC | 866 ms
42,112 KB |
testcase_11 | AC | 369 ms
25,344 KB |
testcase_12 | AC | 552 ms
32,896 KB |
testcase_13 | AC | 907 ms
43,776 KB |
コンパイルメッセージ
Syntax OK
ソースコード
N, K = gets.split.take(2).map(&:to_i) Monsters = N.times.map{ gets.split.take(3).map(&:to_i) } Spells = K.times.map{ gets.split.take(5).map(&:to_i) } M = 1001 cusums = (M + 1).times.map { [0] * (M + 1) } # 座標ごとの総ダメージの累積和 Spells.each{|spell| x, y, w, h, d = spell x += 500 y += 500 xx = [M, x + w + 1].min yy = [M, y + h + 1].min cusums[x][y] += d cusums[xx][yy] += d cusums[xx][y] -= d cusums[x][yy] -= d } M.times{|x| M.times{|y| cusums[x][y + 1] += cusums[x][y] } } M.times{|y| M.times{|x| cusums[x + 1][y] += cusums[x][y] } } # 残り体力の合計 ans = 0 Monsters.each{|monster| x, y, hp = monster x += 500 y += 500 ans += [0, hp - cusums[x][y]].max } p ans