結果
問題 | No.1868 Teleporting Cyanmond |
ユーザー |
![]() |
提出日時 | 2023-08-01 18:47:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 548 bytes |
コンパイル時間 | 3,557 ms |
コンパイル使用メモリ | 249,856 KB |
最終ジャッジ日時 | 2025-02-15 21:22:04 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using namespace std; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll mod=1000000007; ll inf=1000; int main(){ ll n; cin >> n; vector<ll>r(n-1); for (ll i = 0; i < n-1; i++) { cin >> r[i]; r[i]--; } ll now=0; ll x=0; ll nex=0; for (ll i = 0; i < n; i++) { nex=max(nex,r[i]); if (now==i) { now=nex; x++; } } cout << x-1 << endl; }