結果

問題 No.123 カードシャッフル
ユーザー tsunabittsunabit
提出日時 2019-05-06 11:17:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 509 ms / 5,000 ms
コード長 878 bytes
コンパイル時間 3,641 ms
コンパイル使用メモリ 72,572 KB
実行使用メモリ 60,808 KB
最終ジャッジ日時 2023-09-09 13:00:33
合計ジャッジ時間 8,003 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,904 KB
testcase_01 AC 126 ms
53,596 KB
testcase_02 AC 129 ms
55,808 KB
testcase_03 AC 128 ms
55,776 KB
testcase_04 AC 130 ms
55,712 KB
testcase_05 AC 128 ms
55,796 KB
testcase_06 AC 126 ms
55,544 KB
testcase_07 AC 126 ms
56,320 KB
testcase_08 AC 130 ms
56,320 KB
testcase_09 AC 128 ms
55,500 KB
testcase_10 AC 504 ms
60,652 KB
testcase_11 AC 501 ms
60,808 KB
testcase_12 AC 502 ms
60,648 KB
testcase_13 AC 509 ms
60,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No123 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        // カード積み上げ
        ArrayList<Integer> card = new ArrayList<Integer>();
        for(int i = 0; i < n; i++) {
        	card.add(i+1);
        }
        
        ArrayList<Integer> al = new ArrayList<Integer>();
        for(int i = 0; i < m; i++) {
        	al.add(sc.nextInt());
        }
        
        for(int i = 0; i < m; i++) {
        	int temp = al.get(i) - 1;
        	int temp_value = card.get(temp);
        	card.remove(temp);
        	card.add(0 , temp_value);
        }
        System.out.println(card.get(0));
    }
}

0