結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー lllllll88938494lllllll88938494
提出日時 2022-01-12 23:45:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 258 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 76,052 KB
最終ジャッジ日時 2024-04-27 14:21:02
合計ジャッジ時間 8,257 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,068 KB
testcase_01 AC 35 ms
52,272 KB
testcase_02 AC 34 ms
52,520 KB
testcase_03 AC 36 ms
52,940 KB
testcase_04 AC 34 ms
52,832 KB
testcase_05 AC 35 ms
52,644 KB
testcase_06 AC 35 ms
53,364 KB
testcase_07 AC 35 ms
52,156 KB
testcase_08 AC 36 ms
51,940 KB
testcase_09 AC 35 ms
52,204 KB
testcase_10 AC 35 ms
52,460 KB
testcase_11 AC 35 ms
53,592 KB
testcase_12 AC 36 ms
53,188 KB
testcase_13 AC 38 ms
52,752 KB
testcase_14 AC 46 ms
63,328 KB
testcase_15 AC 46 ms
62,384 KB
testcase_16 AC 35 ms
53,840 KB
testcase_17 AC 43 ms
62,204 KB
testcase_18 AC 35 ms
53,016 KB
testcase_19 AC 46 ms
63,904 KB
testcase_20 AC 45 ms
62,524 KB
testcase_21 AC 35 ms
52,456 KB
testcase_22 AC 47 ms
62,792 KB
testcase_23 AC 71 ms
75,680 KB
testcase_24 AC 92 ms
75,988 KB
testcase_25 AC 241 ms
75,580 KB
testcase_26 AC 50 ms
67,012 KB
testcase_27 AC 50 ms
66,424 KB
testcase_28 AC 238 ms
75,652 KB
testcase_29 AC 58 ms
73,124 KB
testcase_30 AC 70 ms
75,840 KB
testcase_31 AC 70 ms
75,684 KB
testcase_32 AC 54 ms
69,460 KB
testcase_33 AC 240 ms
75,760 KB
testcase_34 AC 245 ms
75,900 KB
testcase_35 AC 244 ms
75,608 KB
testcase_36 AC 250 ms
76,020 KB
testcase_37 AC 258 ms
75,596 KB
testcase_38 AC 247 ms
75,728 KB
testcase_39 AC 250 ms
75,880 KB
testcase_40 AC 247 ms
76,052 KB
testcase_41 AC 242 ms
75,624 KB
testcase_42 AC 248 ms
75,692 KB
testcase_43 AC 36 ms
52,952 KB
testcase_44 AC 238 ms
75,840 KB
testcase_45 AC 35 ms
52,868 KB
testcase_46 AC 247 ms
75,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product
n=int(input())
ns=list(map(int,input().split()))
bs=[list(map(int,input().split())) for i in range(n)]
ans=0
anss=[]
for p in product([0,1],repeat=n):
    cnt=0
    cntb=[]
    for i in range(len(p)):
        if p[i] == 1:
            cnt+= ns[i]
            cntb.append(i)
    if len(cntb) <= 1:
        if ans <= cnt:
            ans = cnt
            anss = cntb
        continue
    for i in range(len(cntb)-1):
        for j in range(i+1,len(cntb)):
            cnt += bs[cntb[i]][cntb[j]]
            
    if ans <= cnt:
        ans = cnt
        anss = cntb
    
print(ans)
anss=list(map(lambda x:x+1,anss))
print(*anss)
            
0