結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー trineutrontrineutron
提出日時 2021-02-08 01:49:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 475 ms / 2,000 ms
コード長 594 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 77,564 KB
最終ジャッジ日時 2023-09-18 04:13:00
合計ジャッジ時間 15,994 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,040 KB
testcase_01 AC 72 ms
71,200 KB
testcase_02 AC 72 ms
71,012 KB
testcase_03 AC 74 ms
71,240 KB
testcase_04 AC 74 ms
71,196 KB
testcase_05 AC 75 ms
71,244 KB
testcase_06 AC 75 ms
70,792 KB
testcase_07 AC 76 ms
71,040 KB
testcase_08 AC 75 ms
71,188 KB
testcase_09 AC 76 ms
71,252 KB
testcase_10 AC 75 ms
71,012 KB
testcase_11 AC 75 ms
71,224 KB
testcase_12 AC 77 ms
71,244 KB
testcase_13 AC 76 ms
71,144 KB
testcase_14 AC 87 ms
76,080 KB
testcase_15 AC 87 ms
75,828 KB
testcase_16 AC 80 ms
74,996 KB
testcase_17 AC 87 ms
76,024 KB
testcase_18 AC 77 ms
71,196 KB
testcase_19 AC 91 ms
75,964 KB
testcase_20 AC 87 ms
75,728 KB
testcase_21 AC 76 ms
71,188 KB
testcase_22 AC 89 ms
76,044 KB
testcase_23 AC 143 ms
76,872 KB
testcase_24 AC 188 ms
76,944 KB
testcase_25 AC 475 ms
77,524 KB
testcase_26 AC 112 ms
77,040 KB
testcase_27 AC 98 ms
76,388 KB
testcase_28 AC 466 ms
77,244 KB
testcase_29 AC 124 ms
76,948 KB
testcase_30 AC 143 ms
76,868 KB
testcase_31 AC 138 ms
77,072 KB
testcase_32 AC 114 ms
77,100 KB
testcase_33 AC 468 ms
77,176 KB
testcase_34 AC 464 ms
77,528 KB
testcase_35 AC 465 ms
77,564 KB
testcase_36 AC 464 ms
77,524 KB
testcase_37 AC 463 ms
77,272 KB
testcase_38 AC 465 ms
77,516 KB
testcase_39 AC 460 ms
77,524 KB
testcase_40 AC 464 ms
77,212 KB
testcase_41 AC 465 ms
77,524 KB
testcase_42 AC 467 ms
77,300 KB
testcase_43 AC 75 ms
71,228 KB
testcase_44 AC 464 ms
77,196 KB
testcase_45 AC 73 ms
71,184 KB
testcase_46 AC 465 ms
77,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

n = int(input())
a = list(map(int, input().split()))
b = [list(map(int, input().split())) for i in range(n)]

def calc(s):
    res = 0
    for i in range(n):
        if not s[i]:
            continue
        res += a[i]
        for j in range(i + 1, n):
            if s[j]:
                res += b[i][j]
    return res

ans = -1
ans_s = []
for s in itertools.product(range(2), repeat=n):
    if sum(s) == 0:
        continue
    score = calc(s)
    if score > ans:
        ans = score
        ans_s = s
print(ans)
ans_t = [i + 1 for i in range(n) if ans_s[i]]
print(*ans_t)
0