結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー ygd.ygd.
提出日時 2021-06-16 23:36:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 600 ms / 2,000 ms
コード長 770 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 77,244 KB
最終ジャッジ日時 2023-08-30 05:00:37
合計ジャッジ時間 18,679 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,668 KB
testcase_01 AC 74 ms
71,688 KB
testcase_02 AC 75 ms
71,496 KB
testcase_03 AC 75 ms
71,148 KB
testcase_04 AC 72 ms
71,512 KB
testcase_05 AC 75 ms
71,304 KB
testcase_06 AC 74 ms
71,724 KB
testcase_07 AC 73 ms
71,500 KB
testcase_08 AC 73 ms
71,328 KB
testcase_09 AC 73 ms
71,604 KB
testcase_10 AC 75 ms
71,756 KB
testcase_11 AC 73 ms
71,524 KB
testcase_12 AC 75 ms
71,468 KB
testcase_13 AC 74 ms
71,352 KB
testcase_14 AC 84 ms
76,080 KB
testcase_15 AC 85 ms
76,512 KB
testcase_16 AC 82 ms
76,156 KB
testcase_17 AC 85 ms
76,376 KB
testcase_18 AC 75 ms
71,524 KB
testcase_19 AC 89 ms
76,548 KB
testcase_20 AC 83 ms
76,412 KB
testcase_21 AC 73 ms
71,756 KB
testcase_22 AC 86 ms
76,460 KB
testcase_23 AC 152 ms
76,824 KB
testcase_24 AC 193 ms
76,980 KB
testcase_25 AC 600 ms
76,712 KB
testcase_26 AC 93 ms
76,540 KB
testcase_27 AC 89 ms
76,252 KB
testcase_28 AC 592 ms
77,060 KB
testcase_29 AC 112 ms
77,048 KB
testcase_30 AC 152 ms
77,136 KB
testcase_31 AC 153 ms
77,036 KB
testcase_32 AC 101 ms
77,244 KB
testcase_33 AC 597 ms
76,720 KB
testcase_34 AC 598 ms
76,948 KB
testcase_35 AC 598 ms
77,116 KB
testcase_36 AC 596 ms
76,592 KB
testcase_37 AC 596 ms
76,908 KB
testcase_38 AC 596 ms
76,696 KB
testcase_39 AC 595 ms
76,968 KB
testcase_40 AC 595 ms
76,892 KB
testcase_41 AC 588 ms
77,004 KB
testcase_42 AC 594 ms
77,148 KB
testcase_43 AC 71 ms
71,488 KB
testcase_44 AC 597 ms
77,136 KB
testcase_45 AC 73 ms
71,556 KB
testcase_46 AC 596 ms
76,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import inf


def main():
    N = int(input()); INF = float("inf")
    A = list(map(int,input().split()))
    B = [list(map(int,input().split())) for _ in range(N)]

    mx = -INF
    idx = -1

    for i in range(1,1<<N): #1個以上鳴らすので1から
        score = 0
        for j in range(N):
            if (i>>j)&1 == 1:
                score += A[j]
        for p in range(N):
            for q in range(p+1,N):
                if (i>>p)&1 == 1 and (i>>q)&1 == 1:
                    score += B[p][q]
        if score > mx:
            mx = score
            idx = i
    print(mx)
    ret = []
    for i in range(N):
        if (idx>>i)&1 == 1:
            ret.append(i+1) #1-index
    print(*ret)
    
        

if __name__ == '__main__':
    main()
0