結果

問題 No.123 カードシャッフル
ユーザー r.suzuki
提出日時 2016-01-03 22:41:59
言語 Java
(openjdk 23)
結果
AC  
実行時間 612 ms / 5,000 ms
コード長 562 bytes
コンパイル時間 3,699 ms
コンパイル使用メモリ 74,808 KB
実行使用メモリ 48,752 KB
最終ジャッジ日時 2024-09-19 10:58:16
合計ジャッジ時間 8,260 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No_123second {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> card = new LinkedList<Integer>();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] shuffle = new int[m];

		for (int i = 1; i <= n; i++) {
			card.add(i);
		}

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

		for (int s : shuffle) {
			int i = card.remove(s - 1);
			card.offerFirst(i);
		}

		System.out.println(card.peek());
		sc.close();

	}

}
0