結果

問題 No.60 魔法少女
ユーザー gigurururugigurururu
提出日時 2014-11-10 00:17:14
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,395 ms / 5,000 ms
コード長 510 bytes
コンパイル時間 36 ms
コンパイル使用メモリ 11,504 KB
実行使用メモリ 71,436 KB
最終ジャッジ日時 2023-08-27 05:20:55
合計ジャッジ時間 13,719 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,108 KB
testcase_01 AC 82 ms
15,108 KB
testcase_02 AC 82 ms
15,156 KB
testcase_03 AC 496 ms
33,740 KB
testcase_04 AC 1,077 ms
59,188 KB
testcase_05 AC 1,110 ms
64,244 KB
testcase_06 AC 1,393 ms
70,356 KB
testcase_07 AC 1,183 ms
64,984 KB
testcase_08 AC 1,001 ms
58,780 KB
testcase_09 AC 827 ms
54,584 KB
testcase_10 AC 1,328 ms
69,668 KB
testcase_11 AC 700 ms
49,776 KB
testcase_12 AC 981 ms
59,968 KB
testcase_13 AC 1,395 ms
71,436 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def g;gets.split.map(&:to_i);end
n,k=g
e=(1..n).map{g}
t=(1..k).map{g}
ex=e.map{|x,_|x}
ey=e.map{|x,y|y}
xn=(t.map{|x,_|x}+ex).min
xx=(t.map{|x,y,w|x+w}+ex).max
yn=(t.map{|x,y|y}+ey).min
yx=(t.map{|x,y,w,h|y+h}+ey).max

m=(yn..yx+1).map{[0]*(xx-xn+1+1)}

t.each{|x,y,w,h,d|
  x-=xn;y-=yn
  m[y][x]+=d
  m[y][x+w+1]-=d
  m[y+h+1][x]-=d
  m[y+h+1][x+w+1]+=d
}
a=[0]*(xx-xn+1)
m.map!{|i|
  s=0
  a=a.zip(i.map{|j|s+=j}).map{|j,l|j+l}
}

p e.map{|x,y,h|[h-m[y-yn][x-xn],0].max}.inject(:+)
0