結果
| 問題 |
No.1360 [Zelkova 4th Tune] 協和音
|
| コンテスト | |
| ユーザー |
lllllll88938494
|
| 提出日時 | 2022-01-12 23:45:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 279 ms / 2,000 ms |
| コード長 | 671 bytes |
| コンパイル時間 | 175 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 76,160 KB |
| 最終ジャッジ日時 | 2024-11-15 16:54:31 |
| 合計ジャッジ時間 | 9,464 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 |
ソースコード
from itertools import product
n=int(input())
ns=list(map(int,input().split()))
bs=[list(map(int,input().split())) for i in range(n)]
ans=0
anss=[]
for p in product([0,1],repeat=n):
cnt=0
cntb=[]
for i in range(len(p)):
if p[i] == 1:
cnt+= ns[i]
cntb.append(i)
if len(cntb) <= 1:
if ans <= cnt:
ans = cnt
anss = cntb
continue
for i in range(len(cntb)-1):
for j in range(i+1,len(cntb)):
cnt += bs[cntb[i]][cntb[j]]
if ans <= cnt:
ans = cnt
anss = cntb
print(ans)
anss=list(map(lambda x:x+1,anss))
print(*anss)
lllllll88938494