結果

問題 No.1104 オンライン点呼
ユーザー simansiman
提出日時 2023-09-13 05:18:52
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,281 bytes
コンパイル時間 3,656 ms
コンパイル使用メモリ 103,608 KB
実行使用メモリ 7,384 KB
最終ジャッジ日時 2023-09-13 05:19:02
合計ジャッジ時間 7,049 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 85 ms
5,448 KB
testcase_02 AC 79 ms
5,436 KB
testcase_03 AC 58 ms
5,440 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 35 ms
4,424 KB
testcase_08 AC 15 ms
4,376 KB
testcase_09 AC 43 ms
7,384 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 23 ms
4,376 KB
testcase_12 AC 37 ms
4,476 KB
testcase_13 AC 30 ms
4,380 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 48 ms
4,676 KB
testcase_16 WA -
testcase_17 AC 34 ms
4,376 KB
testcase_18 AC 45 ms
4,680 KB
testcase_19 AC 66 ms
4,908 KB
testcase_20 AC 71 ms
5,208 KB
testcase_21 AC 71 ms
5,204 KB
testcase_22 AC 62 ms
4,920 KB
testcase_23 AC 46 ms
4,412 KB
testcase_24 AC 21 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 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;

struct Node {
  int id;
  ll t;

  Node(int id = -1, ll t = -1) {
    this->id = id;
    this->t = t;
  }

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

int main() {
  ll N, K;
  cin >> N >> K;

  vector<ll> A(N);
  vector<ll> B(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> B[i];
  }

  priority_queue <Node, vector<Node>, greater<Node>> pque;
  vector<ll> time(N, LLONG_MAX);
  ll ans = 0;
  time[0] = 0;

  if (N >= 2) {
    pque.push(Node(1, A[0] + B[1]));
  }
  if (N >= 3) {
    pque.push(Node(2, A[0] + B[2] + K));
  }

  while (not pque.empty()) {
    Node node = pque.top();
    pque.pop();

    if (time[node.id] <= node.t) continue;
    time[node.id] = node.t;
    ans = max(ans, node.t);

    if (node.id + 1 < N) {
      pque.push(Node(node.id + 1, node.t + A[node.id] + B[node.id + 1]));
    }
    if (node.id + 2 < N) {
      pque.push(Node(node.id + 2, node.t + A[node.id] + B[node.id + 2] + K));
    }
  }

  cout << ans << endl;

  return 0;
}
0