結果

問題 No.123 カードシャッフル
ユーザー jimanojimano
提出日時 2018-02-12 15:22:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 210 ms / 5,000 ms
コード長 758 bytes
コンパイル時間 3,666 ms
コンパイル使用メモリ 76,064 KB
実行使用メモリ 50,576 KB
最終ジャッジ日時 2024-05-03 12:55:24
合計ジャッジ時間 5,783 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
37,168 KB
testcase_01 AC 53 ms
37,332 KB
testcase_02 AC 52 ms
36,988 KB
testcase_03 AC 52 ms
37,168 KB
testcase_04 AC 53 ms
36,948 KB
testcase_05 AC 53 ms
37,292 KB
testcase_06 AC 54 ms
37,184 KB
testcase_07 AC 54 ms
36,952 KB
testcase_08 AC 53 ms
37,224 KB
testcase_09 AC 53 ms
36,692 KB
testcase_10 AC 192 ms
50,456 KB
testcase_11 AC 200 ms
50,220 KB
testcase_12 AC 208 ms
50,328 KB
testcase_13 AC 210 ms
50,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;

public class No0123 {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input1 = br.readLine().split(" ");
		int n = Integer.parseInt(input1[0]);
		int m = Integer.parseInt(input1[1]);
		LinkedList<Integer> list = new LinkedList<>();
		for (int i = 0; i < n; i++) {
			list.add(i + 1);
		}

		String[] input2 = br.readLine().split(" ");
		for (int i = 0; i < m; i++) {
			int idx = Integer.parseInt(input2[i]);
			int ret = list.remove(idx - 1);
			list.addFirst(ret);
		}

		System.out.println(list.get(0));
	}
}
0