結果

問題 No.1868 Teleporting Cyanmond
ユーザー simansiman
提出日時 2022-03-12 01:55:58
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 920 bytes
コンパイル時間 2,154 ms
コンパイル使用メモリ 107,112 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 11:10:38
合計ジャッジ時間 3,779 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 35 ms
4,348 KB
testcase_04 AC 23 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 6 ms
4,352 KB
testcase_07 AC 17 ms
4,348 KB
testcase_08 AC 12 ms
4,352 KB
testcase_09 AC 16 ms
4,352 KB
testcase_10 AC 32 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 9 ms
4,348 KB
testcase_13 AC 18 ms
4,352 KB
testcase_14 AC 35 ms
4,348 KB
testcase_15 AC 23 ms
4,352 KB
testcase_16 AC 5 ms
4,348 KB
testcase_17 AC 8 ms
4,352 KB
testcase_18 AC 37 ms
4,348 KB
testcase_19 AC 38 ms
4,352 KB
testcase_20 AC 38 ms
4,352 KB
testcase_21 AC 38 ms
4,348 KB
testcase_22 AC 38 ms
4,352 KB
testcase_23 AC 38 ms
4,348 KB
testcase_24 AC 38 ms
4,352 KB
testcase_25 AC 38 ms
4,352 KB
testcase_26 AC 38 ms
4,352 KB
testcase_27 AC 38 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

struct Node {
  int idx;
  int r;

  Node(int idx = -1, int r = -1) {
    this->idx = idx;
    this->r = r;
  }

  bool operator>(const Node &n) const {
    return r < n.r;
  }
};

int main() {
  int N;
  cin >> N;
  priority_queue <Node, vector<Node>, greater<Node>> pque;
  for (int i = 1; i <= N - 1; ++i) {
    int r;
    cin >> r;
    pque.push(Node(i, r));
  }

  int ans = 0;
  int cur = N;
  while (cur > 1) {
    int next = N;
    while (not pque.empty() && cur <= pque.top().r) {
      Node node = pque.top();
      next = min(next, node.idx);
      pque.pop();
    }
    cur = next;
    ++ans;
  }

  cout << ans << endl;

  return 0;
}
0