結果
| 問題 |
No.3158 Collect Stamps
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-10 09:27:46 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 762 ms / 2,000 ms |
| コード長 | 344 bytes |
| コンパイル時間 | 275 ms |
| コンパイル使用メモリ | 12,160 KB |
| 実行使用メモリ | 10,368 KB |
| 最終ジャッジ日時 | 2025-08-10 09:27:52 |
| 合計ジャッジ時間 | 6,163 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
from itertools import permutations
n, m, k = map(int, input().split())
a = set(map(lambda x: int(x) - 1, input().split()))
t = [list(map(int, input().split())) for _ in range(n)]
ans = 10**18
for p in permutations(range(n), m):
if p[-1] not in a:
continue
ans = min(ans, sum(t[p[i]][p[i+1]] for i in range(m-1)))
print(ans)