結果
問題 | No.1995 CHIKA Road |
ユーザー | lloyz |
提出日時 | 2022-07-01 23:16:49 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,027 bytes |
コンパイル時間 | 168 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 155,364 KB |
最終ジャッジ日時 | 2024-05-04 17:46:34 |
合計ジャッジ時間 | 7,635 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
60,416 KB |
testcase_01 | AC | 42 ms
54,272 KB |
testcase_02 | AC | 49 ms
53,888 KB |
testcase_03 | AC | 47 ms
54,400 KB |
testcase_04 | AC | 48 ms
54,784 KB |
testcase_05 | AC | 66 ms
64,768 KB |
testcase_06 | AC | 420 ms
82,100 KB |
testcase_07 | AC | 1,925 ms
94,668 KB |
testcase_08 | AC | 65 ms
65,920 KB |
testcase_09 | AC | 59 ms
64,384 KB |
testcase_10 | AC | 162 ms
81,536 KB |
testcase_11 | TLE | - |
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 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
ソースコード
from collections import defaultdict from heapq import heapify, heappop, heappush from bisect import bisect_right n, m = map(int, input().split()) Edge = defaultdict(list) A = set() for _ in range(m): a, b = map(int, input().split()) Edge[a - 1].append((b - 1, 2 * b - 2 * a - 1)) A.add(a - 1) A.add(n - 1) sortA = sorted(A) m = len(sortA) INF = 10**18 DP = defaultdict(lambda: INF) DP[0] = 0 H = [0] seen = set() heapify(H) while H: cp = heappop(H) if cp == n - 1: print(DP[n - 1]) break ccost = DP[cp] for np, dcost in Edge[cp]: if ccost + dcost >= DP[np]: continue DP[np] = ccost + dcost if np in seen: continue seen.add(np) heappush(H, np) idx = bisect_right(sortA, cp) for i in range(idx, m): np = sortA[i] if ccost + 2 * (np - cp) > DP[np]: break DP[np] = ccost + 2 * (np - cp) if np in seen: continue seen.add(np) heappush(H, np)