結果

問題 No.519 アイドルユニット
ユーザー maspymaspy
提出日時 2020-03-28 01:10:39
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 397 ms / 1,000 ms
コード長 599 bytes
コンパイル時間 1,198 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 15,860 KB
最終ジャッジ日時 2023-08-30 17:13:29
合計ジャッジ時間 5,960 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 384 ms
13,868 KB
testcase_01 AC 395 ms
15,860 KB
testcase_02 AC 146 ms
11,976 KB
testcase_03 AC 35 ms
9,044 KB
testcase_04 AC 20 ms
8,536 KB
testcase_05 AC 20 ms
8,676 KB
testcase_06 AC 20 ms
8,596 KB
testcase_07 AC 20 ms
8,736 KB
testcase_08 AC 20 ms
8,740 KB
testcase_09 AC 22 ms
8,656 KB
testcase_10 AC 25 ms
8,924 KB
testcase_11 AC 35 ms
9,124 KB
testcase_12 AC 20 ms
8,700 KB
testcase_13 AC 34 ms
9,060 KB
testcase_14 AC 35 ms
8,928 KB
testcase_15 AC 35 ms
8,988 KB
testcase_16 AC 36 ms
9,024 KB
testcase_17 AC 35 ms
9,180 KB
testcase_18 AC 35 ms
9,040 KB
testcase_19 AC 34 ms
8,932 KB
testcase_20 AC 34 ms
8,956 KB
testcase_21 AC 35 ms
9,104 KB
testcase_22 AC 35 ms
9,168 KB
testcase_23 AC 35 ms
9,132 KB
testcase_24 AC 61 ms
9,876 KB
testcase_25 AC 63 ms
10,168 KB
testcase_26 AC 64 ms
10,260 KB
testcase_27 AC 63 ms
10,192 KB
testcase_28 AC 64 ms
10,140 KB
testcase_29 AC 382 ms
13,932 KB
testcase_30 AC 381 ms
13,776 KB
testcase_31 AC 380 ms
13,840 KB
testcase_32 AC 397 ms
15,688 KB
testcase_33 AC 20 ms
8,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from functools import lru_cache

N = int(readline())
F = tuple(tuple(map(int, line.split())) for line in readlines())


@lru_cache(None)
def f(S):
    if not S:
        return 0
    i = (S & (-S)).bit_length() - 1
    ret = 0
    for j in range(i + 1, N):
        if not S & (1 << j):
            continue
        T = S - (1 << i) - (1 << j)
        x = f(T) + F[i][j]
        if ret < x:
            ret = x
    return ret


full = (1 << N) - 1
print(f(full))
0