結果

問題 No.123 カードシャッフル
ユーザー koukonko
提出日時 2015-12-12 14:29:00
言語 Java
(openjdk 23)
結果
AC  
実行時間 582 ms / 5,000 ms
コード長 553 bytes
コンパイル時間 2,194 ms
コンパイル使用メモリ 74,188 KB
実行使用メモリ 48,380 KB
最終ジャッジ日時 2024-09-15 08:43:40
合計ジャッジ時間 6,665 ms
ジャッジサーバーID
(参考情報)
judge2 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

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