結果

問題 No.397 NO MORE KADOMATSU
ユーザー simansiman
提出日時 2021-02-26 10:50:07
言語 Ruby
(3.3.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 11,432 KB
実行使用メモリ 31,940 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 02:51:52
合計ジャッジ時間 3,634 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
30,904 KB
testcase_01 AC 105 ms
31,296 KB
testcase_02 AC 104 ms
30,684 KB
testcase_03 AC 109 ms
31,232 KB
testcase_04 AC 106 ms
31,072 KB
testcase_05 AC 110 ms
30,748 KB
testcase_06 AC 111 ms
31,572 KB
testcase_07 AC 113 ms
31,000 KB
testcase_08 AC 105 ms
30,688 KB
testcase_09 AC 107 ms
31,500 KB
testcase_10 AC 143 ms
31,940 KB
testcase_11 AC 106 ms
31,292 KB
testcase_12 AC 123 ms
31,500 KB
testcase_13 AC 129 ms
31,060 KB
testcase_14 AC 132 ms
30,848 KB
testcase_15 AC 128 ms
31,236 KB
testcase_16 AC 108 ms
31,060 KB
testcase_17 AC 106 ms
30,748 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)

updated = true
ans = []

while updated
  updated = false

  (N - 1).times do |i|
    next if A[i] <= A[i + 1]

    A[i], A[i + 1] = A[i + 1], A[i]
    ans << [i, i + 1]
    updated = true
    break
  end
end

puts ans.size
puts ans.map { |u, v| "#{u} #{v}" }
STDOUT.flush
gets
0