結果

問題 No.123 カードシャッフル
ユーザー LeonardoneLeonardone
提出日時 2015-10-16 22:12:40
言語 Ruby
(3.3.0)
結果
AC  
実行時間 450 ms / 5,000 ms
コード長 387 bytes
コンパイル時間 60 ms
コンパイル使用メモリ 11,456 KB
実行使用メモリ 21,704 KB
最終ジャッジ日時 2023-09-28 23:59:42
合計ジャッジ時間 3,264 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,252 KB
testcase_01 AC 80 ms
15,124 KB
testcase_02 AC 81 ms
15,248 KB
testcase_03 AC 85 ms
15,288 KB
testcase_04 AC 83 ms
15,212 KB
testcase_05 AC 83 ms
15,336 KB
testcase_06 AC 86 ms
15,120 KB
testcase_07 AC 81 ms
15,124 KB
testcase_08 AC 80 ms
15,340 KB
testcase_09 AC 80 ms
15,348 KB
testcase_10 AC 144 ms
21,336 KB
testcase_11 AC 450 ms
21,524 KB
testcase_12 AC 293 ms
21,596 KB
testcase_13 AC 299 ms
21,704 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#! ruby
# yukicoder My Practice
# author: Leornadone @ NEETSDKASU

(N, M), A = $<.map{|x| x.chomp.split.map(&:to_i)}

card_top = [0, []]
ref = card_top
1.upto(N) do |i|
	ref[1] = [i, []]
	ref = ref[1]
end

A.each do |ai|
	ref = card_top
	ai.pred.times do
		ref = ref[1]
	end
	new_top = ref[1]
	ref[1] = new_top[1]
	new_top[1] = card_top[1]
	card_top[1] = new_top
end

puts card_top[1][0]
0