結果

問題 No.123 カードシャッフル
ユーザー mitsuomitsuo
提出日時 2016-05-05 00:03:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 370 ms / 5,000 ms
コード長 796 bytes
コンパイル時間 2,150 ms
コンパイル使用メモリ 78,548 KB
実行使用メモリ 62,332 KB
最終ジャッジ日時 2024-04-15 11:45:46
合計ジャッジ時間 5,545 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
54,088 KB
testcase_01 AC 128 ms
54,052 KB
testcase_02 AC 129 ms
54,224 KB
testcase_03 AC 127 ms
54,244 KB
testcase_04 AC 128 ms
54,364 KB
testcase_05 AC 129 ms
54,076 KB
testcase_06 AC 127 ms
54,152 KB
testcase_07 AC 127 ms
54,276 KB
testcase_08 AC 129 ms
54,056 KB
testcase_09 AC 130 ms
53,868 KB
testcase_10 AC 327 ms
62,036 KB
testcase_11 AC 343 ms
62,332 KB
testcase_12 AC 368 ms
62,332 KB
testcase_13 AC 370 ms
62,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package jp.fedom.challange.yuki.q123;

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] input = new String[2];
		int i = 0;
		while (sc.hasNext()) {
			input[i] = sc.nextLine();
			i++;
		}

		System.out.println(solve(input));

		sc.close();
	}

	public static int solve(String[] in) {
		int N = Integer.valueOf(in[0].split(" ")[0]);
		int M = Integer.valueOf(in[0].split(" ")[1]);

		List<Integer> stack = new ArrayList<>();

		for (int i = 1; i < N + 1; i++) {
			stack.add(i);
		}

		for (String s : in[1].split(" ")) {
			int p = Integer.valueOf(s) - 1;
			int i = stack.get(p);
			stack.remove(p);
			stack.add(0, i);
		}
		return stack.get(0);
	}
}
0