結果

問題 No.1687 What the Heck?
ユーザー simansiman
提出日時 2021-09-26 04:23:05
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 271 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 11,256 KB
実行使用メモリ 37,552 KB
最終ジャッジ日時 2023-09-19 02:48:44
合計ジャッジ時間 3,901 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,048 KB
testcase_01 AC 83 ms
15,048 KB
testcase_02 AC 84 ms
15,336 KB
testcase_03 AC 84 ms
15,240 KB
testcase_04 AC 85 ms
15,028 KB
testcase_05 AC 84 ms
15,260 KB
testcase_06 AC 83 ms
15,032 KB
testcase_07 AC 129 ms
24,444 KB
testcase_08 AC 152 ms
26,496 KB
testcase_09 AC 128 ms
24,348 KB
testcase_10 AC 113 ms
20,216 KB
testcase_11 AC 115 ms
20,384 KB
testcase_12 AC 212 ms
37,544 KB
testcase_13 AC 212 ms
37,412 KB
testcase_14 AC 212 ms
37,500 KB
testcase_15 AC 214 ms
37,416 KB
testcase_16 AC 211 ms
37,180 KB
testcase_17 AC 88 ms
16,608 KB
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - idx
Syntax OK

ソースコード

diff #

N = gets.to_i
P = gets.split.map(&:to_i)
idx = P.index(N) + 1
rounds = Hash.new

P.each.with_index(1) do |x, i|
  rounds[x] = i
end

i = N
sum = (1..N).sum

while i >= 2 && 2 * rounds[i - 1] <= rounds[i]
  sum -= rounds[i]
  i -= 1
end

puts [0, sum - 2 * rounds[i]].max
0