結果

問題 No.519 アイドルユニット
ユーザー tpynerivertpyneriver
提出日時 2020-12-13 18:32:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 1,000 ms
コード長 746 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 81,900 KB
実行使用メモリ 83,796 KB
最終ジャッジ日時 2023-10-20 03:59:57
合計ジャッジ時間 3,769 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
83,796 KB
testcase_01 AC 143 ms
83,632 KB
testcase_02 AC 90 ms
77,620 KB
testcase_03 AC 62 ms
68,660 KB
testcase_04 AC 39 ms
55,580 KB
testcase_05 AC 38 ms
55,580 KB
testcase_06 AC 40 ms
55,580 KB
testcase_07 AC 45 ms
62,104 KB
testcase_08 AC 50 ms
64,504 KB
testcase_09 AC 56 ms
66,668 KB
testcase_10 AC 57 ms
66,664 KB
testcase_11 AC 60 ms
68,644 KB
testcase_12 AC 39 ms
55,580 KB
testcase_13 AC 61 ms
68,660 KB
testcase_14 AC 62 ms
68,660 KB
testcase_15 AC 62 ms
68,644 KB
testcase_16 AC 62 ms
68,660 KB
testcase_17 AC 60 ms
68,660 KB
testcase_18 AC 60 ms
68,660 KB
testcase_19 AC 62 ms
68,660 KB
testcase_20 AC 62 ms
68,660 KB
testcase_21 AC 61 ms
68,660 KB
testcase_22 AC 62 ms
68,660 KB
testcase_23 AC 63 ms
68,660 KB
testcase_24 AC 69 ms
70,764 KB
testcase_25 AC 68 ms
70,764 KB
testcase_26 AC 70 ms
70,764 KB
testcase_27 AC 69 ms
70,764 KB
testcase_28 AC 70 ms
70,764 KB
testcase_29 AC 152 ms
83,648 KB
testcase_30 AC 146 ms
83,664 KB
testcase_31 AC 155 ms
83,612 KB
testcase_32 AC 148 ms
83,656 KB
testcase_33 AC 41 ms
55,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline
from collections import Counter

def popcount(i):
    assert 0 <= i < 0x100000000
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24

INF = 10**18
N = int(readline())
A = [list(map(int, readline().split())) for _ in range(N)]

dp = Counter()
dp[0] = -INF
for i in range(N):
    dpnew = Counter()
    for k, v in dp.items():
        if popcount(k) <= N-i-2:
            dpnew[k|(1<<i)] = max(dpnew[k|(1<<i)], dp[k])
        for j in range(N):
            if (1<<j) & k:
                key = k^(1<<j)
                dpnew[key] = max(dpnew[key], dp[k] + A[i][j])
    dp = dpnew.copy()
print(dp[0])
0