結果

問題 No.90 品物の並び替え
ユーザー けむけむけむけむ
提出日時 2021-07-27 23:52:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 985 bytes
コンパイル時間 913 ms
コンパイル使用メモリ 11,008 KB
実行使用メモリ 97,568 KB
最終ジャッジ日時 2023-10-01 04:25:36
合計ジャッジ時間 8,696 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,328 KB
testcase_01 AC 442 ms
16,568 KB
testcase_02 AC 16 ms
8,136 KB
testcase_03 AC 42 ms
9,332 KB
testcase_04 AC 59 ms
9,336 KB
testcase_05 AC 502 ms
16,468 KB
testcase_06 AC 352 ms
16,468 KB
testcase_07 AC 20 ms
8,316 KB
testcase_08 AC 17 ms
8,164 KB
testcase_09 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def narabe(N):
    if N == 2:
        result = [[0, 1], [1, 0]]
        return result
    result = []
    bef_f = narabe(N - 1)
    for i in range(len(bef_f)):
        li1 = bef_f[i]
        for j in range(len(li1) + 1):
            li2 = [] + li1
            li2.insert(j, N - 1)
            result.append(li2)
    return result

def shinamono(N, M, scores):
    lists = narabe(N)
    score_list = []
    for i in range(len(lists)):
        score = 0
        li = lists[i]
        for j in range(M):
            a = li.index(scores[j][0])
            b = li.index(scores[j][1])
            if a < b:
                score += scores[j][2]
        score_list.append(score)
    result = max(score_list)
    return result

def main():
    N, M = map(int, input().split())
    scores = [[0, 0, 0] for i in range(M)]
    for j in range(M):
        scores[j][0], scores[j][1], scores[j][2] = map(int, input().split())
    print(shinamono(N, M, scores))

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