結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー ygd.ygd.
提出日時 2021-06-16 23:33:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 822 bytes
コンパイル時間 1,424 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 77,048 KB
最終ジャッジ日時 2023-08-30 04:58:06
合計ジャッジ時間 19,174 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,360 KB
testcase_01 AC 73 ms
71,292 KB
testcase_02 AC 72 ms
71,524 KB
testcase_03 AC 73 ms
71,116 KB
testcase_04 AC 75 ms
71,244 KB
testcase_05 AC 75 ms
71,296 KB
testcase_06 AC 75 ms
71,424 KB
testcase_07 AC 74 ms
71,696 KB
testcase_08 AC 75 ms
71,700 KB
testcase_09 AC 75 ms
71,216 KB
testcase_10 AC 74 ms
71,424 KB
testcase_11 AC 73 ms
71,404 KB
testcase_12 AC 73 ms
71,116 KB
testcase_13 AC 74 ms
71,204 KB
testcase_14 AC 97 ms
76,144 KB
testcase_15 AC 86 ms
76,380 KB
testcase_16 AC 82 ms
75,992 KB
testcase_17 AC 86 ms
76,548 KB
testcase_18 AC 74 ms
71,220 KB
testcase_19 AC 88 ms
76,420 KB
testcase_20 AC 85 ms
76,492 KB
testcase_21 AC 75 ms
71,296 KB
testcase_22 AC 87 ms
76,044 KB
testcase_23 AC 152 ms
77,032 KB
testcase_24 AC 195 ms
76,884 KB
testcase_25 AC 601 ms
76,880 KB
testcase_26 AC 94 ms
76,520 KB
testcase_27 AC 91 ms
76,280 KB
testcase_28 AC 597 ms
77,004 KB
testcase_29 AC 113 ms
76,872 KB
testcase_30 AC 153 ms
76,828 KB
testcase_31 AC 154 ms
76,640 KB
testcase_32 AC 100 ms
76,752 KB
testcase_33 AC 597 ms
76,852 KB
testcase_34 AC 601 ms
76,980 KB
testcase_35 AC 598 ms
76,428 KB
testcase_36 AC 598 ms
76,876 KB
testcase_37 AC 598 ms
76,756 KB
testcase_38 AC 594 ms
76,980 KB
testcase_39 AC 599 ms
76,532 KB
testcase_40 AC 598 ms
76,532 KB
testcase_41 AC 600 ms
76,420 KB
testcase_42 AC 601 ms
76,796 KB
testcase_43 AC 74 ms
71,220 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

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<<N):
        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
    if mx == -INF:
        print(0)
        ret = []
        print(*ret)
        exit()
    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