結果

問題 No.519 アイドルユニット
ユーザー sue_charosue_charo
提出日時 2017-05-28 22:51:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,225 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 12,016 KB
実行使用メモリ 15,316 KB
最終ジャッジ日時 2023-10-21 14:28:37
合計ジャッジ時間 4,679 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    n = II()
    F = IAI(n)
    return (n, F)


def solve(n, F):
    all_list = set()
    for i in range(1, n + 1):
        all_list.add(i)
    all_used = set()

    def find(set_used, set_left):
        if len(set_left) == 0:
            return 0

        now_ret = -1

        for i in itertools.combinations(list(set_left), 2):
            next_set_used = copy.copy(set_used)
            next_set_used.add(i[0])
            next_set_used.add(i[1])
            next_set_left = copy.copy(set_left)
            next_set_left.remove(i[0])
            next_set_left.remove(i[1])
            now_ret = max(now_ret, find(next_set_used, next_set_left) + F[i[0] - 1][i[1] - 1])

        return now_ret

    ans = find(all_used, all_list)
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()
0