結果

問題 No.123 カードシャッフル
ユーザー jimanojimano
提出日時 2018-02-12 15:22:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 196 ms / 5,000 ms
コード長 758 bytes
コンパイル時間 5,128 ms
コンパイル使用メモリ 73,088 KB
実行使用メモリ 63,120 KB
最終ジャッジ日時 2023-08-16 03:22:10
合計ジャッジ時間 6,104 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,588 KB
testcase_01 AC 44 ms
50,016 KB
testcase_02 AC 44 ms
47,640 KB
testcase_03 AC 44 ms
49,648 KB
testcase_04 AC 45 ms
49,664 KB
testcase_05 AC 44 ms
49,492 KB
testcase_06 AC 45 ms
49,548 KB
testcase_07 AC 47 ms
49,772 KB
testcase_08 AC 46 ms
49,632 KB
testcase_09 AC 44 ms
49,636 KB
testcase_10 AC 171 ms
63,120 KB
testcase_11 AC 177 ms
61,416 KB
testcase_12 AC 196 ms
61,084 KB
testcase_13 AC 187 ms
60,952 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