結果

問題 No.3013 ハチマキ買い星人
ユーザー hamikan
提出日時 2025-09-05 20:27:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 898 bytes
コンパイル時間 2,472 ms
コンパイル使用メモリ 205,012 KB
実行使用メモリ 7,944 KB
最終ジャッジ日時 2025-09-05 20:27:42
合計ジャッジ時間 13,041 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 RE * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using p = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M, P, Y, ans = 0;
    cin >> N >> M >> P >> Y;
    vector graph(N, vector<p>());
    while(M--) {
        int A, B, C;
        cin >> A >> B >> C;
        A--, B--;
        graph[A].emplace_back(B, C);
        graph[B].emplace_back(A, C);
    }
    priority_queue<p, vector<p>, greater<p>> now;
    vector<int> cost(N, INT_MAX);
    now.push({0, 0});
    cost[0] = 0;
    while(!now.empty()) {
        auto [w, n] = now.top();
        now.pop();
        for(auto [to, c] : graph[n]) {
            if(cost[to] <= w + c) continue;
            now.push({w + c, to});
            cost[to] = w + c;
        }
    }
    while(P--) {
        int D, E;
        cin >> D >> E;
        ans = max(ans, (Y - cost[D-1]) / E);
    }
    cout << ans << endl;
}
0