結果

問題 No.123 カードシャッフル
ユーザー HKDnetHKDnet
提出日時 2015-01-12 00:14:04
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 322 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 11,456 KB
実行使用メモリ 21,728 KB
最終ジャッジ日時 2023-09-04 04:39:51
合計ジャッジ時間 2,686 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,164 KB
testcase_01 AC 82 ms
15,288 KB
testcase_02 AC 88 ms
15,244 KB
testcase_03 AC 83 ms
15,140 KB
testcase_04 AC 86 ms
15,164 KB
testcase_05 AC 81 ms
15,132 KB
testcase_06 WA -
testcase_07 AC 84 ms
15,024 KB
testcase_08 AC 81 ms
15,244 KB
testcase_09 AC 86 ms
15,092 KB
testcase_10 AC 135 ms
21,476 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: `-' after local variable or literal is interpreted as binary operator
Main.rb:3: warning: even though it seems like unary operator
Main.rb:11: warning: mismatched indentations at 'elsif' with 'if' at 9
Main.rb:13: warning: mismatched indentations at 'else' with 'if' at 9
Main.rb:16: warning: mismatched indentations at 'end' with 'else' at 8
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n,m = gets.chomp.split.map{|str| str.to_i}
shuffles = gets.chomp.split.map{|str| str.to_i}
target = shuffles[m -1]
(m - 2).downto(0) {|idx|
    tmp = shuffles[idx]
    if target == 1
    	target = tmp
    else 
    	if tmp < target
			next
		elsif tmp > target
			target -= 1
		else
			target = 1
		end
	end
}
puts target
0