結果
問題 | No.90 品物の並び替え |
ユーザー | rlangevin |
提出日時 | 2023-01-08 18:24:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 84 ms / 5,000 ms |
コード長 | 450 bytes |
コンパイル時間 | 460 ms |
コンパイル使用メモリ | 87,020 KB |
実行使用メモリ | 76,512 KB |
最終ジャッジ日時 | 2023-08-22 04:04:41 |
合計ジャッジ時間 | 2,102 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,068 KB |
testcase_01 | AC | 83 ms
76,092 KB |
testcase_02 | AC | 71 ms
71,212 KB |
testcase_03 | AC | 75 ms
75,624 KB |
testcase_04 | AC | 76 ms
75,608 KB |
testcase_05 | AC | 84 ms
76,260 KB |
testcase_06 | AC | 82 ms
76,512 KB |
testcase_07 | AC | 71 ms
71,144 KB |
testcase_08 | AC | 69 ms
71,304 KB |
testcase_09 | AC | 84 ms
76,244 KB |
ソースコード
N, M = map(int, input().split()) G = [[] for i in range(N)] for i in range(M): A, B, C = map(int, input().split()) G[B].append((A, C)) dp = [-10 ** 18] * (1 << N) dp[0] = 0 for i in range(1 << N): for j in range(N): cnt = 0 if (i >> j) & 1: continue for u, c in G[j]: if (i >> u) & 1: cnt += c dp[i | (1 << j)] = max(dp[i | (1 << j)], dp[i] + cnt) print(dp[-1])