結果

問題 No.77 レンガのピラミッド
ユーザー wotsushiwotsushi
提出日時 2017-04-05 21:14:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 92 ms / 5,000 ms
コード長 279 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 11,188 KB
実行使用メモリ 15,516 KB
最終ジャッジ日時 2023-09-22 20:21:21
合計ジャッジ時間 4,251 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
15,300 KB
testcase_01 AC 88 ms
15,196 KB
testcase_02 AC 88 ms
15,440 KB
testcase_03 AC 88 ms
15,232 KB
testcase_04 AC 89 ms
15,436 KB
testcase_05 AC 90 ms
15,452 KB
testcase_06 AC 90 ms
15,188 KB
testcase_07 AC 89 ms
15,476 KB
testcase_08 AC 88 ms
15,436 KB
testcase_09 AC 89 ms
15,348 KB
testcase_10 AC 88 ms
15,240 KB
testcase_11 AC 87 ms
15,516 KB
testcase_12 AC 87 ms
15,256 KB
testcase_13 AC 89 ms
15,504 KB
testcase_14 AC 89 ms
15,280 KB
testcase_15 AC 87 ms
15,268 KB
testcase_16 AC 87 ms
15,304 KB
testcase_17 AC 87 ms
15,460 KB
testcase_18 AC 89 ms
15,324 KB
testcase_19 AC 89 ms
15,284 KB
testcase_20 AC 89 ms
15,444 KB
testcase_21 AC 92 ms
15,304 KB
testcase_22 AC 91 ms
15,420 KB
testcase_23 AC 90 ms
15,304 KB
testcase_24 AC 89 ms
15,452 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
ans = (1..100).map {|m|
  p, q = (1..199).zip(A).map {|i, a|
    [m - (m - i).abs, 0].max - a.to_i
  }.inject([0, 0]) {|(p, q), x|
    [p + [0, x].max, q - [0, x].min]
  }
  if q >= p
    q
  else
    Float::INFINITY
  end
}.min
puts ans
0