結果
| 問題 | No.357 品物の並び替え (Middle) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-08-24 21:40:50 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 505 bytes | 
| コンパイル時間 | 329 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 11,392 KB | 
| 最終ジャッジ日時 | 2024-11-15 10:35:10 | 
| 合計ジャッジ時間 | 4,471 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | WA * 18 | 
ソースコード
n, m = map(int, input().split())
score = [[0]*n for _ in range(n)]
for _ in range(m):
    a, b, s = map(int, input().split())
    score[a][b] = s
print(*score,sep="\n")
dp = [0]*(1 << n)
for s in range(1 << n):
    for v in range(n):
        tmp=0
        for u in range(n):
            if (s >> u) & 1==0:
                continue
            if (s >> v) & 1 == 0:
                tmp+=score[u][v]
        if dp[s]+tmp >= dp[s | (1 << v)]:
            dp[s | (1 << v)] = dp[s]+tmp
print(dp[(1 << n)-1])
            
            
            
        