結果

問題 No.123 カードシャッフル
ユーザー nCk_cvnCk_cv
提出日時 2016-01-21 02:22:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 541 ms / 5,000 ms
コード長 545 bytes
コンパイル時間 2,874 ms
コンパイル使用メモリ 77,312 KB
実行使用メモリ 64,492 KB
最終ジャッジ日時 2023-10-21 13:39:22
合計ジャッジ時間 7,035 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
57,420 KB
testcase_01 AC 136 ms
57,608 KB
testcase_02 AC 139 ms
57,536 KB
testcase_03 AC 139 ms
57,616 KB
testcase_04 AC 141 ms
57,584 KB
testcase_05 AC 139 ms
57,628 KB
testcase_06 AC 142 ms
57,420 KB
testcase_07 AC 138 ms
57,108 KB
testcase_08 AC 138 ms
57,156 KB
testcase_09 AC 140 ms
57,440 KB
testcase_10 AC 488 ms
61,772 KB
testcase_11 AC 541 ms
64,492 KB
testcase_12 AC 530 ms
63,604 KB
testcase_13 AC 526 ms
63,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[M];
		for(int i = 0; i < M; i++) {
			A[i] = sc.nextInt()-1;
		}
		int[] now = new int[N];
		for(int i = 0; i < N; i++) {
			now[i] = i+1;
		}
		for(int i = 0; i < M; i++) {
			int tmp = now[A[i]];
			for(int j = A[i]; j >= 1; j--) {
				now[j] = now[j-1];
			}
			now[0] = tmp;
		}
		System.out.println(now[0]);
	}
}
0