Problem p02703 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

struct Edge {
  Edge(int64_t t, int64_t A, int64_t B) : to(t), cost_coin(A), cost_time(B) {}
  int64_t to, cost_coin, cost_time;
};

int main() {
  int64_t N, M, S;
  cin >> N >> M >> S;
  vector<int64_t> U(M), V(M), A(M), B(M);
  vector<vector<Edge>> edges(N);
  for (int64_t i = 0; i < M; i++) {
    cin >> U[i] >> V[i] >> A[i] >> B[i];
    U[i]--;
    V[i]--;
    edges[U[i]].emplace_back(V[i], A[i], B[i]);
    edges[V[i]].emplace_back(U[i], A[i], B[i]);
  }

  vector<int64_t> C(N), D(N);
  for (int64_t i = 0; i < N; i++) {
    cin >> C[i] >> D[i];
  }

  const int64_t MAX_COIN = M * 1000;

  constexpr int64_t INF = LLONG_MAX;
  vector<vector<int64_t>> cost(N, vector<int64_t>(MAX_COIN + 1, INF));
  struct Element {
    int64_t node, coin, cost_time;
    bool operator<(const Element &rhs) const {
      return cost_time < rhs.cost_time;
    }
    bool operator>(const Element &rhs) const {
      return cost_time > rhs.cost_time;
    }
  };
  priority_queue<Element, vector<Element>, greater<Element>> pq;

  S = min(S, MAX_COIN);
  for (int64_t i = 0; i <= S; i++) {
    cost[0][i] = 0;
    pq.push({0, i, 0});
  }
  while (!pq.empty()) {
    Element t = pq.top();
    //        cout << t.node << " " << t.coin << " " << t.cost_time << endl;
    pq.pop();
    if (t.cost_time > cost[t.node][t.coin]) {
      continue;
    }

    // 移動可能なら移動
    for (const Edge &e : edges[t.node]) {
      if (e.cost_coin > t.coin) {
        continue;
      }
      int64_t new_cost_time = t.cost_time + e.cost_time;
      int64_t new_coin = t.coin - e.cost_coin;
      if (new_cost_time < cost[e.to][new_coin]) {
        cost[e.to][new_coin] = new_cost_time;
        pq.push({e.to, new_coin, new_cost_time});
      }
    }

    // ここで一回交換
    int64_t new_cost_time = t.cost_time + D[t.node];
    int64_t new_coin = min(MAX_COIN, t.coin + C[t.node]);
    if (new_cost_time < cost[t.node][new_coin]) {
      cost[t.node][new_coin] = new_cost_time;
      pq.push({t.node, new_coin, new_cost_time});
    }
  }

  for (int64_t i = 1; i < N; i++) {
    cout << *min_element(cost[i].begin(), cost[i].end()) << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

struct Edge {
  Edge(int64_t t, int64_t A, int64_t B) : to(t), cost_coin(A), cost_time(B) {}
  int64_t to, cost_coin, cost_time;
};

int main() {
  int64_t N, M, S;
  cin >> N >> M >> S;
  vector<int64_t> U(M), V(M), A(M), B(M);
  vector<vector<Edge>> edges(N);
  for (int64_t i = 0; i < M; i++) {
    cin >> U[i] >> V[i] >> A[i] >> B[i];
    U[i]--;
    V[i]--;
    edges[U[i]].emplace_back(V[i], A[i], B[i]);
    edges[V[i]].emplace_back(U[i], A[i], B[i]);
  }

  vector<int64_t> C(N), D(N);
  for (int64_t i = 0; i < N; i++) {
    cin >> C[i] >> D[i];
  }

  const int64_t MAX_COIN = M * 100;

  constexpr int64_t INF = LLONG_MAX;
  vector<vector<int64_t>> cost(N, vector<int64_t>(MAX_COIN + 1, INF));
  struct Element {
    int64_t node, coin, cost_time;
    bool operator<(const Element &rhs) const {
      return cost_time < rhs.cost_time;
    }
    bool operator>(const Element &rhs) const {
      return cost_time > rhs.cost_time;
    }
  };
  priority_queue<Element, vector<Element>, greater<Element>> pq;

  S = min(S, MAX_COIN);
  for (int64_t i = 0; i <= S; i++) {
    cost[0][i] = 0;
    pq.push({0, i, 0});
  }
  while (!pq.empty()) {
    Element t = pq.top();
    //        cout << t.node << " " << t.coin << " " << t.cost_time << endl;
    pq.pop();
    if (t.cost_time > cost[t.node][t.coin]) {
      continue;
    }

    // 移動可能なら移動
    for (const Edge &e : edges[t.node]) {
      if (e.cost_coin > t.coin) {
        continue;
      }
      int64_t new_cost_time = t.cost_time + e.cost_time;
      int64_t new_coin = t.coin - e.cost_coin;
      if (new_cost_time < cost[e.to][new_coin]) {
        cost[e.to][new_coin] = new_cost_time;
        pq.push({e.to, new_coin, new_cost_time});
      }
    }

    // ここで一回交換
    int64_t new_cost_time = t.cost_time + D[t.node];
    int64_t new_coin = min(MAX_COIN, t.coin + C[t.node]);
    if (new_cost_time < cost[t.node][new_coin]) {
      cost[t.node][new_coin] = new_cost_time;
      pq.push({t.node, new_coin, new_cost_time});
    }
  }

  for (int64_t i = 1; i < N; i++) {
    cout << *min_element(cost[i].begin(), cost[i].end()) << endl;
  }
}