結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー 👑 KazunKazun
提出日時 2021-01-22 02:40:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 621 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 86,756 KB
実行使用メモリ 92,392 KB
最終ジャッジ日時 2023-08-26 17:53:27
合計ジャッジ時間 15,753 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,216 KB
testcase_01 AC 66 ms
71,476 KB
testcase_02 AC 69 ms
71,216 KB
testcase_03 AC 67 ms
71,304 KB
testcase_04 AC 65 ms
71,500 KB
testcase_05 AC 66 ms
71,476 KB
testcase_06 AC 67 ms
71,240 KB
testcase_07 AC 67 ms
71,232 KB
testcase_08 AC 67 ms
71,264 KB
testcase_09 AC 67 ms
71,016 KB
testcase_10 AC 67 ms
71,332 KB
testcase_11 AC 67 ms
71,380 KB
testcase_12 AC 66 ms
71,136 KB
testcase_13 AC 67 ms
71,188 KB
testcase_14 AC 79 ms
76,524 KB
testcase_15 AC 78 ms
76,640 KB
testcase_16 AC 72 ms
76,220 KB
testcase_17 AC 78 ms
76,512 KB
testcase_18 AC 68 ms
71,268 KB
testcase_19 AC 83 ms
76,512 KB
testcase_20 AC 79 ms
76,612 KB
testcase_21 AC 67 ms
71,052 KB
testcase_22 AC 81 ms
76,520 KB
testcase_23 AC 122 ms
77,508 KB
testcase_24 AC 167 ms
77,952 KB
testcase_25 AC 491 ms
80,864 KB
testcase_26 AC 107 ms
77,360 KB
testcase_27 AC 84 ms
76,484 KB
testcase_28 AC 487 ms
80,868 KB
testcase_29 AC 101 ms
77,100 KB
testcase_30 AC 123 ms
77,484 KB
testcase_31 AC 122 ms
77,536 KB
testcase_32 AC 104 ms
77,188 KB
testcase_33 AC 541 ms
92,392 KB
testcase_34 AC 542 ms
92,156 KB
testcase_35 AC 540 ms
92,304 KB
testcase_36 AC 538 ms
92,328 KB
testcase_37 AC 541 ms
92,156 KB
testcase_38 AC 541 ms
92,076 KB
testcase_39 AC 543 ms
91,988 KB
testcase_40 AC 541 ms
92,156 KB
testcase_41 AC 600 ms
92,164 KB
testcase_42 AC 538 ms
91,988 KB
testcase_43 AC 67 ms
71,052 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))
B=[[0]*N for _ in range(N)]
for i in range(N):
    B[i]=list(map(int,input().split()))

inf=float("inf")
DP=[-inf]*(1<<N)
DP[0]=0
Max=-float("inf")

for x in range(1<<N):
    y=x
    M=set()
    for i in range(N):
        if y&1:
            M.add(i)
        y>>=1

    for i in range(N):
        C=0
        if i not in M:
            for j in M:
                C+=B[i][j]

            DP[x|(1<<i)]=DP[x]+A[i]+C

Max=-inf
Arg=inf

for x in range((1<<N)-1,-1,-1):
    if DP[x]>=Max:
        Max=DP[x]
        Arg=x

print(Max)
print(*[i+1 for i in range(N) if Arg&(1<<i)])
0