結果
| 問題 | No.365 ジェンガソート | 
| コンテスト | |
| ユーザー |  iomir | 
| 提出日時 | 2023-03-29 10:35:03 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 29 ms / 2,000 ms | 
| コード長 | 449 bytes | 
| コンパイル時間 | 1,568 ms | 
| コンパイル使用メモリ | 168,704 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-21 04:13:19 | 
| 合計ジャッジ時間 | 3,449 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 41 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
using ll = long long;
const ll INF=1ll<<60;
using vll = vector<ll>;
int main(){
    ll N;
    cin>>N;
    vll A(N),ind(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        A[i]--;
        ind[A[i]]=i;
    }
    ll now=ind[N-1];
    ll ans=N-1;
    while(ans>0){
        if(now<ind[ans-1])break;
        ans--;
        now=ind[ans];
    } 
    cout << ans << endl;
}
            
            
            
        