結果

問題 No.123 カードシャッフル
ユーザー yagi2yagi2
提出日時 2017-04-24 19:22:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 409 ms / 5,000 ms
コード長 665 bytes
コンパイル時間 2,135 ms
コンパイル使用メモリ 72,736 KB
実行使用メモリ 62,588 KB
最終ジャッジ日時 2023-10-11 13:21:39
合計ジャッジ時間 6,131 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,980 KB
testcase_01 AC 118 ms
55,764 KB
testcase_02 AC 117 ms
56,144 KB
testcase_03 AC 116 ms
53,544 KB
testcase_04 AC 116 ms
55,676 KB
testcase_05 AC 116 ms
55,860 KB
testcase_06 AC 116 ms
55,500 KB
testcase_07 AC 117 ms
55,448 KB
testcase_08 AC 116 ms
56,024 KB
testcase_09 AC 117 ms
55,784 KB
testcase_10 AC 374 ms
60,484 KB
testcase_11 AC 392 ms
62,588 KB
testcase_12 AC 409 ms
60,480 KB
testcase_13 AC 407 ms
60,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        List<Integer> trump = new ArrayList<>();
        for (int i = 1; i <= N; i++) {
            trump.add(i);
        }

        for (int i = 0; i < M; i++) {
            int maime = Integer.parseInt(sc.next());
            int tmp = trump.get(maime-1);
            trump.remove(maime-1);
            trump.add(0, tmp);
        }

        System.out.println(trump.get(0));
    }
}
0