結果

問題 No.123 カードシャッフル
ユーザー r.suzukir.suzuki
提出日時 2016-01-03 22:41:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 516 ms / 5,000 ms
コード長 562 bytes
コンパイル時間 3,607 ms
コンパイル使用メモリ 75,436 KB
実行使用メモリ 63,392 KB
最終ジャッジ日時 2023-10-19 14:50:07
合計ジャッジ時間 7,699 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
57,452 KB
testcase_01 AC 132 ms
57,476 KB
testcase_02 AC 131 ms
57,608 KB
testcase_03 AC 131 ms
57,604 KB
testcase_04 AC 132 ms
57,140 KB
testcase_05 AC 129 ms
57,220 KB
testcase_06 AC 131 ms
57,548 KB
testcase_07 AC 130 ms
57,424 KB
testcase_08 AC 133 ms
57,656 KB
testcase_09 AC 131 ms
57,228 KB
testcase_10 AC 481 ms
62,096 KB
testcase_11 AC 506 ms
62,572 KB
testcase_12 AC 512 ms
63,372 KB
testcase_13 AC 516 ms
63,392 KB
権限があれば一括ダウンロードができます

ソースコード

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