結果
問題 | No.2387 Yokan Factory |
ユーザー |
![]() |
提出日時 | 2023-07-21 22:47:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,474 ms / 5,000 ms |
コード長 | 969 bytes |
コンパイル時間 | 184 ms |
コンパイル使用メモリ | 82,476 KB |
実行使用メモリ | 250,396 KB |
最終ジャッジ日時 | 2024-09-22 00:20:26 |
合計ジャッジ時間 | 28,008 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
import heapqdef 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]=Truefor e,c,m in edge[p]:if m>=num and high[e]>h+c:high[e]=h+cheapq.heappush(hq,[h+c,e])return high[-1]def nibun():left,right=-1,len(use)while right-left>1:mid=(right+left)//2dist=daiku(0,use[mid])if dist!=-1 and dist<=X:left=midelse:right=midif left==-1:return leftreturn use[left]import sysinput=sys.stdin.readlineN,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())