結果

問題 No.123 カードシャッフル
ユーザー dogwood0424
提出日時 2018-01-04 20:35:58
言語 Java
(openjdk 23)
結果
AC  
実行時間 614 ms / 5,000 ms
コード長 500 bytes
コンパイル時間 5,026 ms
コンパイル使用メモリ 74,488 KB
実行使用メモリ 48,740 KB
最終ジャッジ日時 2024-12-23 03:45:53
合計ジャッジ時間 8,585 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class No123 {
	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();
		}
		int []b=new int[n];
		for(int i=0;i<n;i++) {
			b[i]=i+1;
		}
		int []t=new int[1];

		for(int i=0;i<m;i++) {
			t[0]=b[a[i]-1];
			for(int j=a[i]-1;j>0;j--) {
				b[j]=b[j-1];
			}
			b[0]=t[0];
		}

		System.out.println(b[0]);
		sc.close();
	}

}
0