結果

問題 No.123 カードシャッフル
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-06 01:04:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 513 ms / 5,000 ms
コード長 676 bytes
コンパイル時間 2,925 ms
コンパイル使用メモリ 71,352 KB
実行使用メモリ 61,088 KB
最終ジャッジ日時 2023-09-17 05:44:49
合計ジャッジ時間 6,084 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,072 KB
testcase_01 AC 123 ms
56,092 KB
testcase_02 AC 125 ms
55,672 KB
testcase_03 AC 124 ms
55,764 KB
testcase_04 AC 124 ms
55,896 KB
testcase_05 AC 123 ms
55,632 KB
testcase_06 AC 124 ms
56,024 KB
testcase_07 AC 122 ms
56,220 KB
testcase_08 AC 123 ms
55,912 KB
testcase_09 AC 120 ms
55,780 KB
testcase_10 AC 440 ms
60,644 KB
testcase_11 AC 513 ms
61,088 KB
testcase_12 AC 482 ms
60,324 KB
testcase_13 AC 480 ms
60,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int n = koko.nextInt();
        int m = koko.nextInt();
        int[] a = new int[m];
        for(int i=0; i<m; i++){
            a[i] = koko.nextInt();
        }
        int[] card = new int[n];
        for(int i=0; i<n; i++){
            card[i]=i;
        }
        for(int i=0; i<m; i++){
            int hozon =card[a[i]-1];
            for(int k=a[i]-2; k>=0; k--){
                card[k+1]=card[k];
            }
            card[0] = hozon;
        }
        System.out.println(card[0]+1);
    
    }
}
0