結果
問題 | No.845 最長の切符 |
ユーザー | neko_the_shadow |
提出日時 | 2019-07-07 17:13:32 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 521 bytes |
コンパイル時間 | 1,289 ms |
コンパイル使用メモリ | 82,388 KB |
実行使用メモリ | 92,240 KB |
最終ジャッジ日時 | 2024-04-15 07:53:19 |
合計ジャッジ時間 | 6,738 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
63,260 KB |
testcase_01 | AC | 44 ms
55,664 KB |
testcase_02 | AC | 45 ms
56,292 KB |
testcase_03 | AC | 46 ms
55,948 KB |
testcase_04 | AC | 45 ms
55,496 KB |
testcase_05 | AC | 46 ms
56,368 KB |
testcase_06 | AC | 45 ms
55,708 KB |
testcase_07 | AC | 46 ms
55,908 KB |
testcase_08 | AC | 97 ms
77,984 KB |
testcase_09 | AC | 59 ms
67,436 KB |
testcase_10 | AC | 725 ms
79,040 KB |
testcase_11 | AC | 126 ms
77,792 KB |
testcase_12 | AC | 143 ms
78,060 KB |
testcase_13 | AC | 106 ms
77,552 KB |
testcase_14 | AC | 85 ms
77,580 KB |
testcase_15 | TLE | - |
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 | -- | - |
ソースコード
import collections, functools n, m = map(int, input().split()) d = [[-1] * n for _ in range(n)] for _ in range(m): a, b, c = map(int, input().split()) a -= 1 b -= 1 d[a][b] = d[b][a] = max(d[a][b], c) @functools.lru_cache() def f(current, history): ans = 0 for nxt in range(n): if history & (1 << nxt) == 0 and d[current][nxt] > 0: ans = max(ans, f(nxt, history | (1 << current)) + d[current][nxt]) return ans ans = max(f(current, 0) for current in range(n)) print(ans)