結果

問題 No.123 カードシャッフル
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-20 15:14:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 542 ms / 5,000 ms
コード長 505 bytes
コンパイル時間 1,920 ms
コンパイル使用メモリ 74,500 KB
実行使用メモリ 59,572 KB
最終ジャッジ日時 2024-04-10 04:10:01
合計ジャッジ時間 5,900 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
53,964 KB
testcase_01 AC 107 ms
52,696 KB
testcase_02 AC 119 ms
53,896 KB
testcase_03 AC 118 ms
54,084 KB
testcase_04 AC 116 ms
53,984 KB
testcase_05 AC 115 ms
54,032 KB
testcase_06 AC 109 ms
52,900 KB
testcase_07 AC 118 ms
53,900 KB
testcase_08 AC 113 ms
53,304 KB
testcase_09 AC 117 ms
53,700 KB
testcase_10 AC 480 ms
59,272 KB
testcase_11 AC 527 ms
59,572 KB
testcase_12 AC 502 ms
59,324 KB
testcase_13 AC 542 ms
59,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] card = new int[N];
    for(int i = 0; i < N; i++) {
      card[i] = i + 1;
    }
    for(int i = 0; i < M; i++) {
      int pos = sc.nextInt() - 1;
      int temp = card[pos];
      for(int j = pos; j > 0; j--) {
        card[j] = card[j - 1];
      }
      card[0] = temp;
    }
    System.out.println(card[0]);
  }
}
0