結果

問題 No.2387 Yokan Factory
ユーザー nikoro256nikoro256
提出日時 2023-07-21 22:47:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,869 ms / 5,000 ms
コード長 969 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 81,484 KB
実行使用メモリ 250,388 KB
最終ジャッジ日時 2023-10-21 22:52:17
合計ジャッジ時間 32,064 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,328 KB
testcase_01 AC 41 ms
53,328 KB
testcase_02 AC 42 ms
53,328 KB
testcase_03 AC 42 ms
53,328 KB
testcase_04 AC 42 ms
53,328 KB
testcase_05 AC 44 ms
53,328 KB
testcase_06 AC 42 ms
53,328 KB
testcase_07 AC 42 ms
53,328 KB
testcase_08 AC 41 ms
53,328 KB
testcase_09 AC 42 ms
53,328 KB
testcase_10 AC 41 ms
53,328 KB
testcase_11 AC 41 ms
53,328 KB
testcase_12 AC 41 ms
53,328 KB
testcase_13 AC 40 ms
53,328 KB
testcase_14 AC 41 ms
53,328 KB
testcase_15 AC 3,610 ms
155,224 KB
testcase_16 AC 2,196 ms
180,544 KB
testcase_17 AC 3,869 ms
250,388 KB
testcase_18 AC 2,113 ms
141,196 KB
testcase_19 AC 1,958 ms
129,260 KB
testcase_20 AC 1,502 ms
114,896 KB
testcase_21 AC 2,933 ms
150,776 KB
testcase_22 AC 1,380 ms
109,548 KB
testcase_23 AC 2,036 ms
130,424 KB
testcase_24 AC 629 ms
102,832 KB
testcase_25 AC 1,172 ms
102,868 KB
testcase_26 AC 2,145 ms
137,628 KB
testcase_27 AC 3,012 ms
159,060 KB
testcase_28 AC 96 ms
76,068 KB
testcase_29 AC 113 ms
76,492 KB
testcase_30 AC 109 ms
76,332 KB
testcase_31 AC 104 ms
75,816 KB
testcase_32 AC 85 ms
75,556 KB
testcase_33 AC 94 ms
75,816 KB
testcase_34 AC 108 ms
76,340 KB
testcase_35 AC 105 ms
76,340 KB
testcase_36 AC 87 ms
75,552 KB
testcase_37 AC 40 ms
53,328 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)
    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