結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,344 KB
testcase_01 AC 73 ms
71,780 KB
testcase_02 AC 73 ms
71,364 KB
testcase_03 AC 74 ms
71,336 KB
testcase_04 AC 72 ms
71,664 KB
testcase_05 AC 73 ms
71,200 KB
testcase_06 AC 73 ms
71,216 KB
testcase_07 AC 72 ms
71,368 KB
testcase_08 AC 73 ms
71,452 KB
testcase_09 AC 71 ms
71,300 KB
testcase_10 AC 73 ms
71,576 KB
testcase_11 AC 72 ms
71,388 KB
testcase_12 AC 74 ms
71,636 KB
testcase_13 AC 74 ms
71,320 KB
testcase_14 AC 84 ms
76,320 KB
testcase_15 AC 86 ms
76,536 KB
testcase_16 AC 80 ms
76,536 KB
testcase_17 AC 83 ms
76,580 KB
testcase_18 AC 73 ms
71,404 KB
testcase_19 AC 86 ms
76,464 KB
testcase_20 AC 85 ms
76,288 KB
testcase_21 AC 73 ms
71,368 KB
testcase_22 AC 86 ms
76,532 KB
testcase_23 AC 151 ms
76,716 KB
testcase_24 AC 193 ms
76,648 KB
testcase_25 AC 606 ms
76,976 KB
testcase_26 AC 93 ms
76,680 KB
testcase_27 AC 91 ms
76,296 KB
testcase_28 AC 597 ms
76,764 KB
testcase_29 AC 111 ms
76,988 KB
testcase_30 AC 152 ms
77,064 KB
testcase_31 AC 151 ms
77,144 KB
testcase_32 AC 98 ms
77,216 KB
testcase_33 AC 598 ms
76,952 KB
testcase_34 AC 592 ms
76,804 KB
testcase_35 AC 597 ms
77,140 KB
testcase_36 AC 599 ms
77,036 KB
testcase_37 AC 598 ms
76,704 KB
testcase_38 AC 595 ms
77,056 KB
testcase_39 AC 593 ms
76,660 KB
testcase_40 AC 599 ms
77,032 KB
testcase_41 AC 598 ms
77,056 KB
testcase_42 AC 596 ms
76,684 KB
testcase_43 AC 74 ms
71,512 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)
        print()
        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