結果
問題 | No.1868 Teleporting Cyanmond |
ユーザー |
![]() |
提出日時 | 2022-04-28 07:49:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 505 bytes |
コンパイル時間 | 878 ms |
コンパイル使用メモリ | 95,044 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-28 07:53:28 |
合計ジャッジ時間 | 2,314 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <functional> #include <queue> #include <map> #include <cmath> #include <iomanip> #include <set> #include <cstdio> #include <string> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n - 1; i++) { cin >> a[i]; } int j = 0; int cnt = 0; while (a[j] != n) { j = max_element(a.begin() + j, a.begin() + a[j]) - a.begin(); cnt++; } cout << cnt + 1 << endl; return 0; }