結果

問題 No.123 カードシャッフル
ユーザー koukonkokoukonko
提出日時 2015-12-12 14:29:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 502 ms / 5,000 ms
コード長 553 bytes
コンパイル時間 2,303 ms
コンパイル使用メモリ 71,724 KB
実行使用メモリ 60,876 KB
最終ジャッジ日時 2023-10-13 11:46:22
合計ジャッジ時間 7,069 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,700 KB
testcase_01 AC 126 ms
55,460 KB
testcase_02 AC 128 ms
55,876 KB
testcase_03 AC 126 ms
55,836 KB
testcase_04 AC 125 ms
55,644 KB
testcase_05 AC 126 ms
55,680 KB
testcase_06 AC 125 ms
55,464 KB
testcase_07 AC 131 ms
55,456 KB
testcase_08 AC 126 ms
56,288 KB
testcase_09 AC 123 ms
55,752 KB
testcase_10 AC 435 ms
59,948 KB
testcase_11 AC 502 ms
60,876 KB
testcase_12 AC 491 ms
60,844 KB
testcase_13 AC 502 ms
60,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		try {
			Scanner scan = new Scanner(System.in);
			int N = scan.nextInt();
			int[] card = new int[N];
			int M = scan.nextInt();
			for(int i = 0; i < N; ++i){
				card[i] = i+1;
			}

			while(M-- > 0){
				int num = scan.nextInt()-1;
				int sw = card[num];
				for(int i = num; i > 0; --i){
					card[i] = card[i-1];
				}
				card[0] = sw;
			}

			System.out.println(card[0]);

			scan.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
0