結果

問題 No.365 ジェンガソート
ユーザー rapurasu
提出日時 2016-08-10 14:43:13
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 1,735 ms
コンパイル使用メモリ 157,572 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 08:38:03
合計ジャッジ時間 4,489 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

 #include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
int N;
int a[100001];
int used[100001];
int main(){
    cin>>N;
    REP(i,N){
       cin>>a[i];
       used[i]=false;
    }
    int count=0;
    int temp=N-1;
    for(int i=N;i>0;i--){
       if(used[i])break;
       for(int j=temp;j>=0;j--){
          if(a[j]!=i){
             used[a[j]]=true;
             temp--;
          }else{
             count++;
             temp--;
             break;
          }
       }
    }
    cout<<N-count<<endl;
}
0