結果
| 問題 | 
                            No.1360 [Zelkova 4th Tune] 協和音
                             | 
                    
| コンテスト | |
| ユーザー | 
                             lllllll88938494
                         | 
                    
| 提出日時 | 2022-01-12 23:37:59 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 669 bytes | 
| コンパイル時間 | 439 ms | 
| コンパイル使用メモリ | 82,200 KB | 
| 実行使用メモリ | 76,116 KB | 
| 最終ジャッジ日時 | 2024-11-15 16:44:40 | 
| 合計ジャッジ時間 | 8,979 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 44 WA * 3 | 
ソースコード
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