結果
問題 |
No.1868 Teleporting Cyanmond
|
ユーザー |
|
提出日時 | 2024-04-22 00:09:37 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 635 bytes |
コンパイル時間 | 3,150 ms |
コンパイル使用メモリ | 130,380 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 22:41:07 |
合計ジャッジ時間 | 2,408 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#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]; int l=a[1]; int ma=0; int ans=1; for(int i=2;i<=n-1;i++){ ma=max(ma,a[i]); if(l==i){ l=ma; ans++; } } cout<<ans<<endl; } signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); solved(); }