結果

問題 No.90 品物の並び替え
ユーザー pajannatpajannat
提出日時 2021-04-12 21:51:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 993 bytes
コンパイル時間 853 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 131,656 KB
最終ジャッジ日時 2023-09-11 02:58:35
合計ジャッジ時間 3,345 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

def main():
    # 入力行数が多いとき。
    from sys import stdin
    # 数値として入力一つを読み込み
    N, M = map(int, stdin.readline().rstrip().split())
    # 数値列として読み込み。末尾の改行は取り、空白で分割。
    score_list = []
    for i in range(M):
        score_list_tmp = [int(i) for i in stdin.readline().rstrip().split()]
        score_list.append(score_list_tmp)
    
    import itertools
    # 0からn-1までのリスト
    lis = [x for x in range(N)] 
    # 全ての場合のリストを生成
    permutations_lis = list(itertools.permutations(lis))

    max_score = 0
    for permutations in permutations_lis:
        sum = 0
        for i in range(1,len(permutations)):
            for j in score_list:
                if permutations[i-1]==j[0] and permutations[i]==j[1]:
                    sum += j[2]
        if sum > max_score:
            max_score = sum

    print(max_score)

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