結果
問題 | No.77 レンガのピラミッド |
ユーザー |
|
提出日時 | 2014-11-25 23:34:44 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 92 ms / 5,000 ms |
コード長 | 331 bytes |
コンパイル時間 | 43 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-12-26 02:49:00 |
合計ジャッジ時間 | 3,108 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
コンパイルメッセージ
ruby: warning: shebang line ending with \r may cause problems Syntax OK
ソースコード
#!/usr/bin/rubydef pyramid(n)a=[*1..n-1]a+[n]+a.reverseendN=gets.to_ia=gets.split.map(&:to_i)r=999999999(1..1/0.0).each{|_i|py=pyramid(_i)diff=0abs=0[py.size,a.size].max.times{|i|x=(py[i]||0)-(a[i]||0)diff+=xabs+=x.abs}break if diff>0#p [abs,diff]r=[r,abs/2-diff/2].min}p r