結果

問題 No.90 品物の並び替え
ユーザー na-shna-sh
提出日時 2019-07-11 10:13:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 528 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 15,872 KB
最終ジャッジ日時 2024-04-24 22:28:57
合計ジャッジ時間 14,030 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 WA -
testcase_02 AC 31 ms
10,752 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
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 all(c in x for c in row[:2]):
            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, 0, -1):
        x, m = divmod(x, j)
        lst.append(m)
    cdt = calc(lst)
    if cdt > mx:
        mx = cdt
print(mx)
0