結果

問題 No.90 品物の並び替え
ユーザー na-shna-sh
提出日時 2019-07-11 10:25:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 530 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-04-24 23:13:38
合計ジャッジ時間 6,558 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,624 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())

tab = []
for i in range(M):
    tab.append(list(map(int, input().split())))


def calc(x):
    ans = 0
    for row in tab:
        if all(c in x for c in row[:2]):
            if x.index(row[0]) < x.index(row[1]):
                ans += row[2]
    return ans

mx = 0
for i in range(N ** N):
    lst = []
    x = i
    for j in range(N):
        x, m = divmod(x, N)
        lst.append(m)
    if len(set(lst)) == len(lst):
        cdt = calc(lst)
        if cdt > mx:
            mx = cdt
print(mx)
0