結果

問題 No.123 カードシャッフル
ユーザー taku-techtaku-tech
提出日時 2021-05-19 00:07:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 563 ms / 5,000 ms
コード長 662 bytes
コンパイル時間 4,819 ms
コンパイル使用メモリ 76,360 KB
実行使用メモリ 48,656 KB
最終ジャッジ日時 2024-04-17 08:37:21
合計ジャッジ時間 8,901 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
39,912 KB
testcase_01 AC 124 ms
41,476 KB
testcase_02 AC 129 ms
41,440 KB
testcase_03 AC 119 ms
40,932 KB
testcase_04 AC 120 ms
41,028 KB
testcase_05 AC 123 ms
41,144 KB
testcase_06 AC 125 ms
41,236 KB
testcase_07 AC 118 ms
41,500 KB
testcase_08 AC 119 ms
40,936 KB
testcase_09 AC 123 ms
40,976 KB
testcase_10 AC 535 ms
48,252 KB
testcase_11 AC 472 ms
47,312 KB
testcase_12 AC 540 ms
48,536 KB
testcase_13 AC 563 ms
48,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package card_shuffle;

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class CardShuffle {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[M];
		List<Integer> cardList = new LinkedList<Integer>();

		for(int cardNum = 1; cardNum <= N; cardNum++) {
			cardList.add(cardNum);
		}

		for(int i = 0; i < M; i++) {
			A[i] = sc.nextInt();
		}

		List<Integer> shuffledCard = new LinkedList<>(cardList);
		for(int a: A) {
			shuffledCard.add(0, shuffledCard.remove(a-1));
		}

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

}
0