結果

問題 No.123 カードシャッフル
ユーザー tentententen
提出日時 2020-10-09 13:17:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 463 ms / 5,000 ms
コード長 498 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 72,876 KB
実行使用メモリ 60,460 KB
最終ジャッジ日時 2023-09-27 12:38:18
合計ジャッジ時間 6,195 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,864 KB
testcase_01 AC 112 ms
55,616 KB
testcase_02 AC 113 ms
55,564 KB
testcase_03 AC 114 ms
56,032 KB
testcase_04 AC 117 ms
56,048 KB
testcase_05 AC 118 ms
55,648 KB
testcase_06 AC 116 ms
56,268 KB
testcase_07 AC 117 ms
56,044 KB
testcase_08 AC 118 ms
56,036 KB
testcase_09 AC 118 ms
55,560 KB
testcase_10 AC 463 ms
60,212 KB
testcase_11 AC 437 ms
60,312 KB
testcase_12 AC 437 ms
60,176 KB
testcase_13 AC 463 ms
60,460 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();
        ArrayList<Integer> cards = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            cards.add(i);
        }
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt() - 1;
            cards.add(0, cards.remove(x));
        }
        System.out.println(cards.get(0));
    }
}
0