結果

問題 No.1868 Teleporting Cyanmond
ユーザー shangtian551
提出日時 2024-04-22 00:05:48
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 3,390 ms
コンパイル使用メモリ 129,968 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-10-13 22:36:47
合計ジャッジ時間 5,500 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include<vector>
#include<set>
#include<stack>
#include<array>
#include<string>
#include <cassert>
#include <algorithm>
using namespace std;
#define ll long long 
#define endl "\n"
void solved(){
     int n;
     cin>>n;
     vector<int> a(n+1);
     for(int i=1;i<=n-1;i++) cin>>a[i];
     multiset<int> s;
     int l=a[1];
     s.insert(a[1]);
     int ans=1;
     for(int i=2;i<=n-1;i++){
        s.insert(a[i]);
        if(s.size()==l){
           ans++;
           l=*s.rbegin();
        }
     }
     cout<<ans<<endl;
   

}
signed main(){
   
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    solved();
}
0