結果

問題 No.1607 Kth Maximum Card
ユーザー horitaka1999horitaka1999
提出日時 2021-12-11 00:39:37
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,119 bytes
コンパイル時間 1,556 ms
コンパイル使用メモリ 86,652 KB
実行使用メモリ 376,212 KB
最終ジャッジ日時 2023-09-26 02:07:39
合計ジャッジ時間 49,185 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,472 KB
testcase_01 AC 88 ms
71,536 KB
testcase_02 AC 88 ms
71,464 KB
testcase_03 AC 90 ms
71,684 KB
testcase_04 AC 90 ms
71,520 KB
testcase_05 AC 88 ms
71,436 KB
testcase_06 AC 87 ms
71,448 KB
testcase_07 AC 89 ms
71,652 KB
testcase_08 TLE -
testcase_09 AC 3,454 ms
310,244 KB
testcase_10 TLE -
testcase_11 AC 587 ms
141,828 KB
testcase_12 TLE -
testcase_13 AC 441 ms
118,280 KB
testcase_14 AC 560 ms
138,872 KB
testcase_15 AC 2,660 ms
291,708 KB
testcase_16 AC 429 ms
121,192 KB
testcase_17 AC 241 ms
86,624 KB
testcase_18 AC 1,653 ms
293,872 KB
testcase_19 AC 921 ms
232,104 KB
testcase_20 AC 1,455 ms
285,508 KB
testcase_21 AC 1,362 ms
289,636 KB
testcase_22 AC 3,344 ms
335,832 KB
testcase_23 TLE -
testcase_24 AC 1,262 ms
240,044 KB
testcase_25 AC 660 ms
156,032 KB
testcase_26 AC 850 ms
186,156 KB
testcase_27 AC 1,334 ms
261,072 KB
testcase_28 AC 1,036 ms
204,772 KB
testcase_29 AC 2,553 ms
273,912 KB
testcase_30 TLE -
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 collections import deque
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)]
    q = deque()
    dis[0] = 0
    q.append((0,0))
    while q:
        t,now = q.popleft()
        if t > dis[now]:
            continue
        for next,cost in edge[now]:
            if dis[next] > cost + dis[now]:
                dis[next] = cost + dis[now]
                if cost == 0:
                    q.appendleft((dis[next],next))
                else:
                    q.append((dis[next],next))
    if dis[N-1] <= K -1:
        return True
    else:
        return False

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