結果

問題 No.90 品物の並び替え
ユーザー na-shna-sh
提出日時 2019-07-11 09:10:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 577 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-24 20:31:59
合計ジャッジ時間 10,366 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 row[0] in x and row[1] in x:
            if x.index(row[0]) < x.index(row[1]):
                ans += row[2]
    return ans

a = 1
for i in range(N):
    a *= i + 1

mx = 0
for i in range(a):
    lst = []
    x = i
    for j in range(N - 1, -1, -1):
        x, m = divmod(x, j + 1)
        while m in lst:
            m += 1
        lst.append(m)
    cdt = calc(lst)
    if cdt > mx:
        mx = cdt
print(mx)
0