結果
問題 | No.123 カードシャッフル |
ユーザー |
|
提出日時 | 2021-05-19 00:07:51 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 585 ms / 5,000 ms |
コード長 | 662 bytes |
コンパイル時間 | 6,787 ms |
コンパイル使用メモリ | 74,980 KB |
実行使用メモリ | 48,752 KB |
最終ジャッジ日時 | 2024-10-09 00:03:04 |
合計ジャッジ時間 | 7,951 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
ソースコード
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));}}