結果

問題 No.1607 Kth Maximum Card
ユーザー horitaka1999horitaka1999
提出日時 2021-12-11 00:20:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,092 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 283,732 KB
最終ジャッジ日時 2023-09-26 01:29:39
合計ジャッジ時間 8,683 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
75,628 KB
testcase_01 AC 70 ms
71,404 KB
testcase_02 AC 72 ms
71,284 KB
testcase_03 AC 72 ms
71,264 KB
testcase_04 AC 71 ms
71,508 KB
testcase_05 AC 69 ms
71,052 KB
testcase_06 AC 70 ms
71,108 KB
testcase_07 WA -
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,K = map(int,input().split())
board = []
for _ in range(M):
    u,v,c = map(int,input().split())
    u-=1
    v-=1
    board.append((u,v,c))
from heapq import heappush,heappop
#edge[a].append((b,cost))
def dijekstra(st,dis,edge):
    q = []
    dis[st] = 0
    q.append((0,st))
    while q:
        t,now = heappop(q)
        if t > dis[now]:
            continue
        for next,cost in edge[now]:
            if dis[next] > cost + dis[now]:
                dis[next] = cost + dis[now]
                heappush(q,(dis[next],next))
def is_ok(x):
    edge = [[] for _ in range(N)]
    for i in range(M):
        u,v,c = board[i]
        if c > x:
            edge[u].append((v,1))
            edge[v].append((u,1))
        else:
            edge[u].append((v,0))
            edge[v].append((u,0))
    INF = float('inf')
    dis = [INF for _ in range(N)]
    dijekstra(0,dis,edge)
    if dis[N-1] <= K -1:
        return True
    else:
        return False

ok = 10 ** 5
ng = -1
while ok - ng > 1:
    x = (ng+ok)//2
    if is_ok(x):
        ok = x
    else:
        ng = x
print(ok)
    

0