結果

問題 No.1604 Swap Sort:ONE
ユーザー 小野寺健小野寺健
提出日時 2021-11-14 15:39:03
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 177 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 11,460 KB
実行使用メモリ 19,568 KB
最終ジャッジ日時 2023-08-19 22:28:26
合計ジャッジ時間 5,520 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
19,512 KB
testcase_01 AC 79 ms
15,152 KB
testcase_02 AC 79 ms
15,180 KB
testcase_03 AC 79 ms
15,080 KB
testcase_04 AC 88 ms
15,036 KB
testcase_05 AC 90 ms
15,352 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
P = gets.split(" ").map{|s| s.to_i}

cnt = 0
0.upto(N-2) {|i|
	while P[i] != i + 1 do
		j = P.index(P[i] - 1)
		P[i], P[j] = P[j], P[i]
		cnt += 1
	end
}

puts cnt
0