結果

問題 No.123 カードシャッフル
ユーザー ki_ki33ki_ki33
提出日時 2015-01-11 23:40:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 449 ms / 5,000 ms
コード長 1,279 bytes
コンパイル時間 2,205 ms
コンパイル使用メモリ 76,056 KB
実行使用メモリ 60,604 KB
最終ジャッジ日時 2023-09-03 23:42:03
合計ジャッジ時間 6,379 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
56,500 KB
testcase_01 AC 119 ms
55,924 KB
testcase_02 AC 118 ms
55,644 KB
testcase_03 AC 120 ms
56,324 KB
testcase_04 AC 121 ms
55,564 KB
testcase_05 AC 117 ms
55,856 KB
testcase_06 AC 117 ms
55,716 KB
testcase_07 AC 121 ms
56,200 KB
testcase_08 AC 119 ms
56,132 KB
testcase_09 AC 121 ms
55,860 KB
testcase_10 AC 440 ms
60,560 KB
testcase_11 AC 445 ms
60,444 KB
testcase_12 AC 449 ms
60,604 KB
testcase_13 AC 432 ms
60,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	public static final int C =  1000000007;
	//static boolean MAP[][];
	static int N;
	static int M;
	static int MAX = -1;
	//static int tic[][];
	static boolean NUM[];
	//static int max;
	static int A[];
	static int ST[][];
	//static int p[];
	//static ArrayList<HashSet<Integer>> al;
	static TreeMap<Integer, ArrayList<Integer>> hm;
	//static ArrayList<Integer> al;
	//static int a[][];
	//static char[][] ch;
	//static ArrayList<HashMap<Long, Long>> al;
	//static String a[];
	//static String str;
	//static int[] mach = new int[] {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};

	public static void main(String[] args) {
		StringBuilder sb = new StringBuilder();
		BufferedInputStream bs = new BufferedInputStream(System.in);
		Scanner sc = new Scanner(bs);
		
		
		

		
		
		
		N = sc.nextInt();
		
		M = sc.nextInt();
		int a[] = new int[M];
		for (int i=0; i < M; i++) {
			a[i] = sc.nextInt();
		}
		
		int ans = 1;
		
		for (int i=M-1; i >= 0; i--) {
			if (ans == 1) {
				ans = a[i];
			}else if (ans <= a[i]) {
				ans--;
			}else {
				
			}
		}
		
		System.out.println(ans);
		


	}
	
	
	

}
0