結果

問題 No.123 カードシャッフル
ユーザー discoNekodiscoNeko
提出日時 2016-04-28 22:28:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 221 ms / 5,000 ms
コード長 794 bytes
コンパイル時間 2,307 ms
コンパイル使用メモリ 77,384 KB
実行使用メモリ 60,332 KB
最終ジャッジ日時 2024-04-15 05:12:32
合計ジャッジ時間 4,619 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
50,364 KB
testcase_01 AC 54 ms
50,380 KB
testcase_02 AC 56 ms
50,332 KB
testcase_03 AC 55 ms
50,452 KB
testcase_04 AC 54 ms
50,296 KB
testcase_05 AC 54 ms
50,252 KB
testcase_06 AC 56 ms
50,332 KB
testcase_07 AC 56 ms
50,332 KB
testcase_08 AC 54 ms
50,212 KB
testcase_09 AC 53 ms
50,328 KB
testcase_10 AC 158 ms
56,960 KB
testcase_11 AC 221 ms
60,252 KB
testcase_12 AC 190 ms
60,100 KB
testcase_13 AC 201 ms
60,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);
		String[] str1 = br.readLine().split(" ");
		int[] deck = new int [n];
		for(int i = 0; i < n; i++)
			deck[i] = i+1;
		for(int i = 0; i < m; i++){
			int a = Integer.parseInt(str1[i]) -1;
			int tmp = deck[a];
			for(int j = a; j > 0; j--){
				deck[j] = deck[j-1];
			}
			deck[0] = tmp;
		}
		sb.append(deck[0]);
		System.out.println(sb);
	}
}
0