結果

問題 No.123 カードシャッフル
ユーザー rf141
提出日時 2015-08-09 21:20:19
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 654 bytes
コンパイル時間 3,405 ms
コンパイル使用メモリ 75,328 KB
実行使用メモリ 48,884 KB
最終ジャッジ日時 2024-07-18 06:17:30
合計ジャッジ時間 7,447 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1 RE * 2
other WA * 2 RE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class card{
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = 1; i <= n; i++){
			list.add(i);
		}
		int[] shuffle = new int[m];
		for(int i = 0; i < m; i++){
			shuffle[i] = scan.nextInt();
		}
		System.out.println(cardShuffle(list,shuffle));
	}
	public static int cardShuffle(ArrayList<Integer> list,int[] shuffle){
		for(int i = 0;i < shuffle.length; i++){
			int now = list.get(shuffle[i]);
			list.remove(shuffle[i]);
			list.add(0,now);
		}

		return list.get(0);
	}
}
0