結果

問題 No.326 あみだますたー
ユーザー cielciel
提出日時 2015-12-19 05:08:12
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 268 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 11,600 KB
実行使用メモリ 16,228 KB
最終ジャッジ日時 2023-10-14 14:11:35
合計ジャッジ時間 7,146 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,124 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 86 ms
15,180 KB
testcase_06 AC 89 ms
15,172 KB
testcase_07 AC 88 ms
15,168 KB
testcase_08 AC 92 ms
16,008 KB
testcase_09 AC 96 ms
15,988 KB
testcase_10 AC 95 ms
16,228 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
N=gets.to_i
A=[*1..N]
gets.to_i.times{
	a=gets.to_i
	A[a-1],A[a]=A[a],A[a-1]
}
B=gets.split.map(&:to_i)
R=[]
(N-1).downto(1){|i|
	t=B[i]
	1.upto(i){|j|
		if A[j-1]==t
			R<<[j,j+1]
			A[j-1],A[j]=A[j],A[j-1]
		end
	}
}
p R.size
puts R.map{|e|'%d %d'%e}
0