結果

問題 No.123 カードシャッフル
ユーザー marumaru
提出日時 2016-03-23 22:09:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 491 ms / 5,000 ms
コード長 594 bytes
コンパイル時間 3,772 ms
コンパイル使用メモリ 76,060 KB
実行使用メモリ 59,584 KB
最終ジャッジ日時 2024-04-09 21:12:05
合計ジャッジ時間 6,617 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
53,020 KB
testcase_01 AC 97 ms
52,976 KB
testcase_02 AC 107 ms
54,044 KB
testcase_03 AC 106 ms
53,988 KB
testcase_04 AC 107 ms
54,148 KB
testcase_05 AC 96 ms
52,840 KB
testcase_06 AC 110 ms
53,996 KB
testcase_07 AC 99 ms
54,244 KB
testcase_08 AC 109 ms
54,052 KB
testcase_09 AC 108 ms
53,880 KB
testcase_10 AC 481 ms
59,352 KB
testcase_11 AC 478 ms
59,176 KB
testcase_12 AC 491 ms
59,340 KB
testcase_13 AC 483 ms
59,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class yukicoder_123 {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		
		int[] a = new int[m];
		
		for (int i = 0; i < m; i++) {
			a[i] = stdIn.nextInt();
		}
		
		ArrayList<Integer> list = new ArrayList<Integer>(50);
		
		for (int i = 1; i <= n; i++) {
			list.add(i);
		}
		
		for (int i = 0; i < m; i++) {
			Integer x = list.get(a[i] - 1);
			list.remove(a[i] - 1);
			list.add(0, x);
		}
		
		System.out.println(list.get(0));
	}
}
0