結果
問題 |
No.123 カードシャッフル
|
ユーザー |
|
提出日時 | 2015-10-25 23:05:22 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 20 ms / 5,000 ms |
コード長 | 580 bytes |
コンパイル時間 | 699 ms |
コンパイル使用メモリ | 60,388 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 09:07:43 |
合計ジャッジ時間 | 1,407 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
ソースコード
#include <iostream> #include <algorithm> #include <string> #include <cstring> #include <stack> using namespace std; #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) #define SQR(X) ((X)*(X)) typedef long long ll; typedef unsigned long long ull; typedef long double lb; /* ここからが本編 */ int main(void) { int i,j; int n,m; int a[100000]; int key; cin >> n >> m; rep(i,m) cin >> a[i]; key = a[m-1]; for(i = m-2;i>-1;i--) { if(key == 1) key = a[i]; else if(a[i] >= key) key--; } cout << key << endl; return 0; }