結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー mkawa2mkawa2
提出日時 2021-01-22 23:44:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 289 ms / 2,000 ms
コード長 1,169 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 80,376 KB
最終ジャッジ日時 2023-08-27 23:26:33
合計ジャッジ時間 12,729 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,384 KB
testcase_01 AC 68 ms
71,484 KB
testcase_02 AC 71 ms
71,244 KB
testcase_03 AC 70 ms
71,432 KB
testcase_04 AC 70 ms
71,244 KB
testcase_05 AC 69 ms
71,468 KB
testcase_06 AC 68 ms
71,504 KB
testcase_07 AC 68 ms
71,368 KB
testcase_08 AC 69 ms
71,476 KB
testcase_09 AC 68 ms
71,440 KB
testcase_10 AC 69 ms
71,500 KB
testcase_11 AC 68 ms
71,568 KB
testcase_12 AC 67 ms
71,532 KB
testcase_13 AC 68 ms
71,432 KB
testcase_14 AC 73 ms
76,080 KB
testcase_15 AC 76 ms
76,208 KB
testcase_16 AC 70 ms
71,552 KB
testcase_17 AC 75 ms
76,268 KB
testcase_18 AC 68 ms
71,196 KB
testcase_19 AC 81 ms
76,408 KB
testcase_20 AC 77 ms
76,276 KB
testcase_21 AC 68 ms
71,432 KB
testcase_22 AC 81 ms
76,404 KB
testcase_23 AC 140 ms
78,128 KB
testcase_24 AC 162 ms
78,548 KB
testcase_25 AC 278 ms
80,356 KB
testcase_26 AC 110 ms
77,972 KB
testcase_27 AC 101 ms
77,840 KB
testcase_28 AC 284 ms
80,296 KB
testcase_29 AC 122 ms
78,136 KB
testcase_30 AC 135 ms
78,196 KB
testcase_31 AC 135 ms
78,152 KB
testcase_32 AC 118 ms
78,212 KB
testcase_33 AC 280 ms
80,308 KB
testcase_34 AC 274 ms
80,364 KB
testcase_35 AC 274 ms
80,252 KB
testcase_36 AC 277 ms
80,324 KB
testcase_37 AC 274 ms
80,280 KB
testcase_38 AC 283 ms
80,208 KB
testcase_39 AC 275 ms
80,304 KB
testcase_40 AC 289 ms
80,216 KB
testcase_41 AC 279 ms
80,200 KB
testcase_42 AC 280 ms
80,316 KB
testcase_43 AC 69 ms
71,256 KB
testcase_44 AC 275 ms
80,376 KB
testcase_45 AC 67 ms
71,424 KB
testcase_46 AC 279 ms
80,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split())
def MI1(): return map(int1, sys.stdin.buffer.readline().split())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
inf = 10**19
# md = 998244353
md = 10**9+7

n = II()
aa = LI()
bb = LLI(n)

btos = [0]*(1 << n)
for i in range(n):
    for j in range(i):
        bit = 1 << i | 1 << j
        cur = bb[i][j]
        s = bit
        while s < (1 << n):
            btos[s] += cur
            s = (s+1) | bit

mx = -inf
ans = 0
for bit in range(1, 1 << n):
    cur = sum(aa[i] for i in range(n) if bit >> i & 1)+btos[bit]
    if cur > mx:
        mx = cur
        ans = bit

print(mx)
print(" ".join(str(i+1) for i in range(n) if ans >> i & 1))
0