結果

問題 No.123 カードシャッフル
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-10-02 23:59:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 571 ms / 5,000 ms
コード長 793 bytes
コンパイル時間 2,094 ms
コンパイル使用メモリ 74,300 KB
実行使用メモリ 48,764 KB
最終ジャッジ日時 2024-04-20 14:33:56
合計ジャッジ時間 6,285 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
41,580 KB
testcase_01 AC 124 ms
41,428 KB
testcase_02 AC 123 ms
41,476 KB
testcase_03 AC 121 ms
40,100 KB
testcase_04 AC 123 ms
41,524 KB
testcase_05 AC 124 ms
41,176 KB
testcase_06 AC 125 ms
41,444 KB
testcase_07 AC 126 ms
41,480 KB
testcase_08 AC 128 ms
41,504 KB
testcase_09 AC 126 ms
41,568 KB
testcase_10 AC 509 ms
48,580 KB
testcase_11 AC 571 ms
48,764 KB
testcase_12 AC 556 ms
48,560 KB
testcase_13 AC 557 ms
48,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[] a = new int[m];
        for(int i=0; i<m; i++) a[i] = in.nextInt();

        int[] c = new int[n];
        for(int i=0; i<n; i++) c[i] = i+1;

        for(int i=0; i<m; i++) {
            int t = a[i];
            int top = c[a[i]-1];
            //            System.out.print(c[0]+" ");
            for(int j=t-1; j>=1; j--) {
                int temp = c[j-1];
                c[j] = temp;
                //                System.out.print(c[j-1]+" ");
            }
            c[0] = top;
            //            System.out.println();
        }

        System.out.println(c[0]);
    }
}
0