結果
| 問題 | No.2739 Time is money |
| コンテスト | |
| ユーザー |
koheijkt
|
| 提出日時 | 2026-03-16 18:17:05 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 666 ms / 2,000 ms |
| コード長 | 1,501 bytes |
| 記録 | |
| コンパイル時間 | 164 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 124,036 KB |
| 最終ジャッジ日時 | 2026-03-16 18:17:16 |
| 合計ジャッジ時間 | 10,294 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
import sys, math
sys.setrecursionlimit(10**8)
sys.set_int_max_str_digits(0)
INF = 1e18
MOD = 998244353
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import product, combinations, permutations, groupby, accumulate
from heapq import heapify, heappop, heappush
input = sys.stdin.readline
def I(): return input().rstrip()
def II(): return int(input().rstrip())
def IS(): return input().rstrip().split()
def MII(): return map(int, input().rstrip().split())
def LI(): return list(input().rstrip())
def TII(): return tuple(map(int, input().rstrip().split()))
def LII(): return list(map(int, input().rstrip().split()))
def LSI(): return list(map(str, input().rstrip().split()))
def GMI(): return list(map(lambda x: int(x) - 1, input().rstrip().split()))
def kiriage(a, b): return (a+b-1)//b
N, M, X = MII()
G = [list() for _ in range(N + 1)]
for i in range(M):
u, v, c, t = MII()
G[u].append((v, X*t + c))
G[v].append((u, X*t + c))
kakutei = [False] * (N + 1)
dist = [INF] * (N + 1)
dist[1] = 0
que = []
heappush(que, (0, 1))
while que:
curr_dist, pos = heappop(que)
if kakutei[pos]:
continue
kakutei[pos] = True
for nex, kyori in G[pos]:
if kakutei[nex]:
continue
if dist[nex] > curr_dist + kyori:
dist[nex] = curr_dist + kyori
heappush(que, (dist[nex], nex))
if dist[-1] == INF:
print(-1)
else:
ans = kiriage(dist[-1], X)
print(ans)
koheijkt