結果

問題 No.326 あみだますたー
ユーザー cielciel
提出日時 2015-12-19 05:15:41
言語 Ruby
(3.3.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 302 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 16,216 KB
最終ジャッジ日時 2023-08-27 01:27:48
合計ジャッジ時間 4,818 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,140 KB
testcase_01 AC 79 ms
15,176 KB
testcase_02 AC 85 ms
15,196 KB
testcase_03 AC 87 ms
15,552 KB
testcase_04 AC 87 ms
15,472 KB
testcase_05 AC 78 ms
15,140 KB
testcase_06 AC 77 ms
15,164 KB
testcase_07 AC 76 ms
15,212 KB
testcase_08 AC 79 ms
16,216 KB
testcase_09 AC 87 ms
16,128 KB
testcase_10 AC 87 ms
16,208 KB
testcase_11 AC 77 ms
15,232 KB
testcase_12 AC 81 ms
15,600 KB
testcase_13 AC 79 ms
15,396 KB
testcase_14 AC 76 ms
15,272 KB
testcase_15 AC 78 ms
15,232 KB
testcase_16 AC 79 ms
15,396 KB
testcase_17 AC 77 ms
15,368 KB
testcase_18 AC 76 ms
15,084 KB
testcase_19 AC 80 ms
15,316 KB
testcase_20 AC 72 ms
14,972 KB
testcase_21 AC 78 ms
15,252 KB
testcase_22 AC 86 ms
15,196 KB
testcase_23 AC 85 ms
15,668 KB
testcase_24 AC 91 ms
15,584 KB
testcase_25 AC 81 ms
15,604 KB
testcase_26 AC 78 ms
15,156 KB
testcase_27 AC 83 ms
15,404 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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=[nil]*N
gets.split.each_with_index{|e,i|B[e.to_i-1]=i+1}
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