結果
問題 |
No.3158 Collect Stamps
|
ユーザー |
|
提出日時 | 2025-05-27 14:45:27 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 157 ms / 2,000 ms |
コード長 | 597 bytes |
コンパイル時間 | 539 ms |
コンパイル使用メモリ | 82,044 KB |
実行使用メモリ | 76,624 KB |
最終ジャッジ日時 | 2025-05-27 14:45:31 |
合計ジャッジ時間 | 4,139 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
from itertools import permutations, combinations N,M,K=(int(x) for x in input().split()) L=[i for i in range(N)] A=set(map(int, input().split())) T=[] for i in range(N): a=list(map(int, input().split())) T.append(a) ans=float("inf") for i in combinations(L, M): for j in permutations(i): time=0 L_time=0 for k in range(1, len(j)): time += T[j[k-1]][j[k]] if not int(j[-1]+1) in A: L_time=float("inf") for k in A: L_time = min(L_time, T[j[-1]][k-1]) ans = min(ans, time+L_time) print(ans)