結果

問題 No.123 カードシャッフル
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-12-05 17:28:19
言語 Ruby
(3.3.0)
結果
AC  
実行時間 634 ms / 5,000 ms
コード長 274 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 11,444 KB
実行使用メモリ 28,580 KB
最終ジャッジ日時 2023-08-23 08:47:24
合計ジャッジ時間 4,171 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,020 KB
testcase_01 AC 81 ms
15,076 KB
testcase_02 AC 82 ms
15,112 KB
testcase_03 AC 81 ms
15,252 KB
testcase_04 AC 82 ms
15,264 KB
testcase_05 AC 81 ms
15,172 KB
testcase_06 AC 82 ms
15,284 KB
testcase_07 AC 82 ms
15,080 KB
testcase_08 AC 82 ms
15,088 KB
testcase_09 AC 81 ms
15,048 KB
testcase_10 AC 194 ms
23,436 KB
testcase_11 AC 634 ms
28,476 KB
testcase_12 AC 627 ms
28,340 KB
testcase_13 AC 629 ms
28,580 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
S = A.inject((0 .. N).to_a) do |d,a|
  Array.new(N + 1, 0).tap do |n|
    n[1] = d[a]
    (1 ... a).each do |i|
      n[i + 1] = d[i]
    end
    (a + 1 .. N).each do |i|
      n[i] = d[i]
    end
  end
end
puts S[1]
0