結果
問題 |
No.90 品物の並び替え
|
ユーザー |
|
提出日時 | 2014-12-09 13:45:16 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 2,441 ms / 5,000 ms |
コード長 | 399 bytes |
コンパイル時間 | 172 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-11 18:51:52 |
合計ジャッジ時間 | 4,027 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
score = [0] * 1000 N, M = map(int, raw_input().split()) for t in xrange(M): a, b, c = map(int, raw_input().split()) score[a * N + b] = c def solve(m): res = 0 for i in xrange(0, N): if (m >> i) & 1 == 0: tmp = 0 for j in xrange(0, N): if (m >> j) & 1 == 1: tmp += score[j * N + i] res = max(res, tmp + solve(m | (1 << i))) return res print solve(0)