結果
問題 | No.845 最長の切符 |
ユーザー | convexineq |
提出日時 | 2019-06-29 01:49:45 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 818 bytes |
コンパイル時間 | 89 ms |
コンパイル使用メモリ | 10,976 KB |
実行使用メモリ | 15,256 KB |
最終ジャッジ日時 | 2023-09-14 22:56:31 |
合計ジャッジ時間 | 6,215 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
7,796 KB |
testcase_01 | AC | 17 ms
8,320 KB |
testcase_02 | AC | 20 ms
8,392 KB |
testcase_03 | AC | 17 ms
7,924 KB |
testcase_04 | AC | 17 ms
7,944 KB |
testcase_05 | AC | 16 ms
7,792 KB |
testcase_06 | AC | 16 ms
7,860 KB |
testcase_07 | AC | 16 ms
7,800 KB |
testcase_08 | AC | 21 ms
8,236 KB |
testcase_09 | AC | 17 ms
8,392 KB |
testcase_10 | AC | 74 ms
8,748 KB |
testcase_11 | AC | 22 ms
8,316 KB |
testcase_12 | AC | 32 ms
8,480 KB |
testcase_13 | AC | 20 ms
8,392 KB |
testcase_14 | AC | 23 ms
8,232 KB |
testcase_15 | AC | 885 ms
15,256 KB |
testcase_16 | TLE | - |
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 | -- | - |
ソースコード
# coding: utf-8 # Your code here! n,m = [int(i) for i in input().split()] lrp = [[int(i) for i in input().split()] for _ in range(m)] g = [[1e9]*n for _ in range(n)] for l,r,p in lrp: if g[l-1][r-1] == 1e9: g[l-1][r-1] = p else: g[l-1][r-1] = max(g[l-1][r-1],p) if g[r-1][l-1] == 1e9: g[r-1][l-1] = p else: g[r-1][l-1] = max(g[r-1][l-1],p) L = 1<<(n) dp = [[-1]*16 for _ in range(L)] #dp[i][j]: 位置i, last=j for i in range(n): dp[1<<i][i] = 0 for i in range(L): for now in range(n): if i & (1 << now) == 0: continue if dp[i][now] < 0: continue for j in range(n): if i&(1 << j) != 0: continue if g[j][now] == 1e9: continue dp[i^(1 << j)][j] = max(dp[i^(1 << j)][j], dp[i][now] + g[j][now]) print(max(max(i) for i in dp))