結果

問題 No.1687 What the Heck?
ユーザー simansiman
提出日時 2021-09-26 04:57:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 288 ms / 2,000 ms
コード長 258 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 11,412 KB
実行使用メモリ 37,596 KB
最終ジャッジ日時 2023-09-19 02:48:49
合計ジャッジ時間 4,659 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,084 KB
testcase_01 AC 87 ms
15,056 KB
testcase_02 AC 85 ms
15,076 KB
testcase_03 AC 82 ms
15,268 KB
testcase_04 AC 83 ms
15,144 KB
testcase_05 AC 86 ms
15,072 KB
testcase_06 AC 84 ms
15,304 KB
testcase_07 AC 147 ms
24,104 KB
testcase_08 AC 180 ms
26,572 KB
testcase_09 AC 145 ms
24,336 KB
testcase_10 AC 123 ms
20,300 KB
testcase_11 AC 124 ms
20,468 KB
testcase_12 AC 288 ms
37,292 KB
testcase_13 AC 276 ms
37,596 KB
testcase_14 AC 287 ms
37,432 KB
testcase_15 AC 288 ms
37,528 KB
testcase_16 AC 277 ms
37,220 KB
testcase_17 AC 94 ms
16,548 KB
testcase_18 AC 288 ms
37,392 KB
testcase_19 AC 88 ms
15,140 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
P = gets.split.map(&:to_i)
rounds = Hash.new

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

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

while i >= 1
  score = sum - 2 * rounds[i]
  ans = score if ans < score
  sum -= rounds[i]
  i -= 1
end

puts ans
0