結果

問題 No.90 品物の並び替え
ユーザー けむけむけむけむ
提出日時 2021-07-27 23:54:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,297 ms / 5,000 ms
コード長 985 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 171,964 KB
最終ジャッジ日時 2023-10-01 04:27:02
合計ジャッジ時間 3,613 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,180 KB
testcase_01 AC 199 ms
85,708 KB
testcase_02 AC 72 ms
71,276 KB
testcase_03 AC 86 ms
76,112 KB
testcase_04 AC 93 ms
76,444 KB
testcase_05 AC 184 ms
86,304 KB
testcase_06 AC 161 ms
85,920 KB
testcase_07 AC 81 ms
76,248 KB
testcase_08 AC 71 ms
71,536 KB
testcase_09 AC 1,297 ms
171,964 KB
権限があれば一括ダウンロードができます

ソースコード

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