結果
問題 |
No.3158 Collect Stamps
|
ユーザー |
|
提出日時 | 2025-05-27 14:39:29 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 592 bytes |
コンパイル時間 | 512 ms |
コンパイル使用メモリ | 82,376 KB |
実行使用メモリ | 76,780 KB |
最終ジャッジ日時 | 2025-05-27 14:39:34 |
合計ジャッジ時間 | 4,558 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 24 |
ソースコード
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]][j[k-1]] if not 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)