結果
| 問題 | 
                            No.1360 [Zelkova 4th Tune] 協和音
                             | 
                    
| コンテスト | |
| ユーザー | 
                             hiragn
                         | 
                    
| 提出日時 | 2022-11-24 09:02:03 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 658 bytes | 
| コンパイル時間 | 151 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 17,568 KB | 
| 最終ジャッジ日時 | 2024-09-25 09:03:07 | 
| 合計ジャッジ時間 | 8,197 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 25 TLE * 1 -- * 21 | 
ソースコード
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = [list(map(int, input().split())) for _ in range(n)]
    inf = 1 << 60
    ans = -inf
    ans_bit = 0
    for bit in range(1, 1 << n):
        res = 0
        for i in range(n):
            if bit & (1 << i):
                res += a[i]
        for i in range(n):
            for j in range(i + 1, n):
                if bit & (1 << i) and bit & (1 << j):
                    res += b[i][j]
        if ans < res:
            ans = res
            ans_bit = bit
    print(ans)
    print(*[i + 1 for i in range(n) if ans_bit & (1 << i)])
if __name__ == "__main__":
    main()
            
            
            
        
            
hiragn