結果

問題 No.999 てん vs. ほむ
ユーザー gemmarogemmaro
提出日時 2020-02-28 21:32:56
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 344 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 28,032 KB
最終ジャッジ日時 2024-04-21 17:57:44
合計ジャッジ時間 4,957 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
12,032 KB
testcase_01 AC 82 ms
12,032 KB
testcase_02 AC 86 ms
12,160 KB
testcase_03 AC 88 ms
12,032 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 84 ms
12,032 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 177 ms
25,088 KB
testcase_18 AC 180 ms
25,088 KB
testcase_19 AC 169 ms
24,832 KB
testcase_20 AC 179 ms
25,088 KB
testcase_21 AC 183 ms
27,776 KB
testcase_22 AC 182 ms
27,136 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

N = gets.to_i
AS = gets.chomp.split.map(&:to_i)

remain = AS

diff = 0
loop do
  left = remain[0] - remain[1]
  right = remain[-1] - remain[-2]
  if left < right
    remain.pop
    remain.pop
    diff += right
  else
    remain.shift
    remain.shift
    diff += left
  end
  break if remain.empty?
end

puts diff
0