結果

問題 No.2387 Yokan Factory
ユーザー nikoro256nikoro256
提出日時 2023-07-21 22:45:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 971 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 81,576 KB
実行使用メモリ 250,808 KB
最終ジャッジ日時 2023-10-21 22:48:54
合計ジャッジ時間 27,972 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,468 KB
testcase_01 AC 38 ms
53,468 KB
testcase_02 AC 34 ms
53,468 KB
testcase_03 AC 34 ms
53,468 KB
testcase_04 AC 35 ms
53,468 KB
testcase_05 AC 34 ms
53,468 KB
testcase_06 AC 35 ms
53,468 KB
testcase_07 AC 36 ms
53,468 KB
testcase_08 AC 36 ms
53,468 KB
testcase_09 WA -
testcase_10 AC 37 ms
53,468 KB
testcase_11 AC 35 ms
53,468 KB
testcase_12 AC 34 ms
53,468 KB
testcase_13 AC 33 ms
53,468 KB
testcase_14 AC 33 ms
53,468 KB
testcase_15 AC 2,850 ms
147,596 KB
testcase_16 AC 1,978 ms
181,132 KB
testcase_17 AC 3,360 ms
250,808 KB
testcase_18 AC 1,851 ms
141,292 KB
testcase_19 AC 1,677 ms
129,380 KB
testcase_20 AC 1,343 ms
115,008 KB
testcase_21 AC 2,527 ms
150,780 KB
testcase_22 AC 1,173 ms
109,480 KB
testcase_23 AC 1,872 ms
130,544 KB
testcase_24 AC 544 ms
102,952 KB
testcase_25 AC 1,024 ms
102,988 KB
testcase_26 AC 1,897 ms
137,756 KB
testcase_27 AC 2,601 ms
159,188 KB
testcase_28 AC 84 ms
76,448 KB
testcase_29 AC 101 ms
76,612 KB
testcase_30 AC 94 ms
76,448 KB
testcase_31 AC 88 ms
75,932 KB
testcase_32 AC 73 ms
75,936 KB
testcase_33 AC 83 ms
75,932 KB
testcase_34 AC 94 ms
76,456 KB
testcase_35 AC 93 ms
76,312 KB
testcase_36 AC 79 ms
75,748 KB
testcase_37 AC 36 ms
53,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
def daiku(s,num):
    hq=[]
    heapq.heappush(hq,[0,s])
    high=[10**14+1 for _ in range(N)]
    use=[False for _ in range(N)]
    while len(hq)!=0:
        h,p=heapq.heappop(hq)
        if not use[p]:
            use[p]=True
            for e,c,m in edge[p]:
                if m>=num and high[e]>h+c:
                    high[e]=h+c
                    heapq.heappush(hq,[h+c,e])
    return high[-1]

def nibun():
    left,right=-1,len(use)-1
    while right-left>1:
        mid=(right+left)//2
        dist=daiku(0,use[mid])
        if dist!=-1 and dist<=X:
            left=mid
        else:
            right=mid
    if left==-1:
        return left
    return use[left]

import sys
input=sys.stdin.readline
N,M,X=map(int,input().split())
edge=[[] for _ in range(N)]
use=set()
for _ in range(M):
    u,v,a,b=map(int,input().split())
    use.add(b)
    edge[u-1].append([v-1,a,b])
    edge[v-1].append([u-1,a,b])
use=list(use)
use.sort()
print(nibun())
0