結果

問題 No.123 カードシャッフル
ユーザー kroton
提出日時 2015-01-10 22:16:41
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 335 bytes
コンパイル時間 1,725 ms
コンパイル使用メモリ 159,592 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-13 03:35:56
合計ジャッジ時間 3,106 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int A[100010];

int main(){
	int N, M;
	cin >> N >> M;

	for(int i=0;i<M;i++)
		cin >> A[i];

	int target = 1;
	for(int i=M-1;i>=0;i--){
		int p = A[i];

		if(target > p)
			continue;

		if(target == 1){
			target = p;
		} else {
			--target;
		}
	}

	cout << target << endl;
	return 0;
}
0