結果

問題 No.397 NO MORE KADOMATSU
ユーザー miraxialmiraxial
提出日時 2016-07-15 23:24:33
言語 Ruby
(3.3.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 283 bytes
コンパイル時間 38 ms
コンパイル使用メモリ 11,448 KB
実行使用メモリ 31,496 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-24 00:17:23
合計ジャッジ時間 3,294 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
31,328 KB
testcase_01 AC 97 ms
30,868 KB
testcase_02 AC 98 ms
31,008 KB
testcase_03 AC 101 ms
31,184 KB
testcase_04 AC 103 ms
31,048 KB
testcase_05 AC 104 ms
31,336 KB
testcase_06 AC 97 ms
31,080 KB
testcase_07 AC 98 ms
31,496 KB
testcase_08 AC 100 ms
31,140 KB
testcase_09 AC 100 ms
30,916 KB
testcase_10 AC 99 ms
30,828 KB
testcase_11 AC 101 ms
30,900 KB
testcase_12 AC 99 ms
31,332 KB
testcase_13 AC 103 ms
31,216 KB
testcase_14 AC 101 ms
31,328 KB
testcase_15 AC 101 ms
30,912 KB
testcase_16 AC 99 ms
30,872 KB
testcase_17 AC 99 ms
30,896 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
a=gets.split.map &:to_i
b=a.sort
c=0
d=[]
while a!=b do
  n.times do |i|
    if a[i]!=b[i]
      g=a[i..-1].index(b[i])+i
      d<< [i,g]
      gg=a[i]
      a[i]=a[g]
      a[g]=gg
      c+=1
      break
    end
  end
end
p c
d.each do |e|
  print e[0]," ",e[1],"\n"
end
0