結果

問題 No.397 NO MORE KADOMATSU
ユーザー miraxialmiraxial
提出日時 2016-07-15 23:21:52
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 299 bytes
コンパイル時間 427 ms
コンパイル使用メモリ 11,480 KB
実行使用メモリ 31,556 KB
平均クエリ数 2.94
最終ジャッジ日時 2023-09-23 11:04:58
合計ジャッジ時間 5,403 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
30,764 KB
testcase_01 AC 105 ms
30,896 KB
testcase_02 AC 104 ms
30,660 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 103 ms
31,076 KB
testcase_10 WA -
testcase_11 AC 107 ms
31,232 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 104 ms
30,896 KB
testcase_17 AC 107 ms
30,884 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
  break if c==3
end
p c
d.each do |e|
  print e[0]," ",e[1],"\n"
end
0