結果
問題 | No.1360 [Zelkova 4th Tune] 協和音 |
ユーザー |
![]() |
提出日時 | 2021-01-22 21:52:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 815 ms / 2,000 ms |
コード長 | 590 bytes |
コンパイル時間 | 2,817 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 76,416 KB |
最終ジャッジ日時 | 2024-12-27 23:51:34 |
合計ジャッジ時間 | 20,979 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 47 |
ソースコード
from itertools import combinations n = int(input()) a = list(map(int, input().split())) b = [list(map(int, input().split())) for _ in range(n)] res = -10**18 r = [] for i in range(1 << n): s = [] tmp = 0 for j in range(n): if i & (1 << j): s.append(j) tmp += a[j] if len(s) == 0: continue if len(s) >= 2: for l in list(combinations(s, 2)): x = l[0] y = l[1] tmp += b[x][y] if tmp > res: res = tmp r = s print(res) for i in range(len(r)): r[i] = r[i]+1 print(*r)