結果

問題 No.2739 Time is money
ユーザー kenken714kenken714
提出日時 2024-04-13 22:38:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,159 bytes
コンパイル時間 2,483 ms
コンパイル使用メモリ 204,404 KB
実行使用メモリ 21,808 KB
最終ジャッジ日時 2024-04-14 11:29:27
合計ジャッジ時間 9,822 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,136 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 362 ms
19,936 KB
testcase_04 WA -
testcase_05 AC 240 ms
17,308 KB
testcase_06 AC 324 ms
20,280 KB
testcase_07 AC 412 ms
20,488 KB
testcase_08 AC 490 ms
20,476 KB
testcase_09 AC 412 ms
20,632 KB
testcase_10 WA -
testcase_11 AC 463 ms
20,664 KB
testcase_12 AC 373 ms
19,360 KB
testcase_13 AC 338 ms
19,380 KB
testcase_14 AC 312 ms
19,536 KB
testcase_15 AC 256 ms
21,808 KB
testcase_16 AC 250 ms
19,312 KB
testcase_17 AC 385 ms
20,908 KB
testcase_18 AC 418 ms
20,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll d[210000]; 
struct edge { ll to, cost; };
vector<edge> g[210000];
void dijkstra(ll a) {
	priority_queue<P, vector<P>, greater<P> > q;
	fill(d, d + 210000, INF);
	d[a] = 0;
	q.push(P(0, a));
	while (!q.empty()) {
		P p = q.top();
		q.pop();
		ll v = p.second;
		if (d[v] < p.first) continue;
		REP(i, g[v].size()) {
			edge e = g[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				q.push(P(d[e.to], e.to));
			}
		}
	}
}
int main(){
    ll n, m, x;
    cin >> n >> m >> x;
    REP(i, m){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        g[a].push_back({b, c + x * d});
        g[b].push_back({a, c + x * d});
    }
    dijkstra(0);
    cout << (d[n - 1] + x - 1) / x << endl;
}
0