結果

問題 No.2387 Yokan Factory
ユーザー komkompikomkompi
提出日時 2023-07-22 18:07:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 4,175 ms / 5,000 ms
コード長 902 bytes
コンパイル時間 1,874 ms
コンパイル使用メモリ 81,520 KB
実行使用メモリ 269,984 KB
最終ジャッジ日時 2023-10-24 00:37:26
合計ジャッジ時間 32,630 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,476 KB
testcase_01 AC 38 ms
53,476 KB
testcase_02 AC 39 ms
53,476 KB
testcase_03 AC 39 ms
53,476 KB
testcase_04 AC 39 ms
53,476 KB
testcase_05 AC 40 ms
53,476 KB
testcase_06 AC 39 ms
53,476 KB
testcase_07 AC 40 ms
53,476 KB
testcase_08 AC 39 ms
53,476 KB
testcase_09 AC 38 ms
53,476 KB
testcase_10 AC 41 ms
53,476 KB
testcase_11 AC 40 ms
53,476 KB
testcase_12 AC 40 ms
53,476 KB
testcase_13 AC 40 ms
53,476 KB
testcase_14 AC 39 ms
53,476 KB
testcase_15 AC 1,650 ms
159,412 KB
testcase_16 AC 660 ms
128,724 KB
testcase_17 AC 2,570 ms
269,984 KB
testcase_18 AC 3,029 ms
204,596 KB
testcase_19 AC 2,000 ms
171,276 KB
testcase_20 AC 971 ms
125,320 KB
testcase_21 AC 2,802 ms
182,688 KB
testcase_22 AC 1,083 ms
123,108 KB
testcase_23 AC 3,678 ms
206,072 KB
testcase_24 AC 1,081 ms
128,216 KB
testcase_25 AC 1,427 ms
140,668 KB
testcase_26 AC 4,175 ms
234,704 KB
testcase_27 AC 1,065 ms
156,672 KB
testcase_28 AC 111 ms
76,788 KB
testcase_29 AC 139 ms
77,568 KB
testcase_30 AC 151 ms
77,568 KB
testcase_31 AC 147 ms
76,992 KB
testcase_32 AC 112 ms
76,228 KB
testcase_33 AC 109 ms
76,284 KB
testcase_34 AC 171 ms
77,572 KB
testcase_35 AC 152 ms
77,308 KB
testcase_36 AC 78 ms
72,704 KB
testcase_37 AC 40 ms
53,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
import heapq as hq

def dijkstra(edges,start,size):
    n_node=len(edges)
    costs=[float("inf") for i in range(n_node)]
    
    
    queue=[(0,start)]
    
    while queue:
        cost,now=hq.heappop(queue)
        if costs[now]>cost:
            costs[now]=cost
            if now==N-1:
                break
            
            for n_cost,width,nxt in edges[now]:
                if width>=size:
                    hq.heappush(queue,(cost+n_cost,nxt))
 
    return costs[:]

N,M,X=map(int,input().split())

edges=[[] for i in range(N)]

for _ in range(M):
    u,v,a,b=map(int,input().split())
    edges[u-1].append((a,b,v-1))
    edges[v-1].append((a,b,u-1))
    

high=10**9+1
low=-1

while high-low>1:
    middle=(high+low)//2
    
    costs=dijkstra(edges,0,middle)
    
    if costs[-1]<=X:
        low=middle
    else:
        high=middle


print(low)
0