結果
| 問題 |
No.3158 Collect Stamps
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-18 11:15:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 220 ms / 2,000 ms |
| コード長 | 347 bytes |
| コンパイル時間 | 990 ms |
| コンパイル使用メモリ | 82,352 KB |
| 実行使用メモリ | 76,628 KB |
| 最終ジャッジ日時 | 2025-05-18 11:15:46 |
| 合計ジャッジ時間 | 5,051 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)