結果

問題 No.90 品物の並び替え
コンテスト
ユーザー piconic_X
提出日時 2016-08-25 00:50:56
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 984 ms / 5,000 ms
+ 51µs
コード長 561 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2026-10-12 01:32:57
合計ジャッジ時間 4,604 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from itertools import permutations

def eval_(N, regs, t):
    score = 0
    for j in range(N):
        for i in range(j):
            score += regs[t[i]][t[j]]
    return score

def solve(N, regs):
    max_ = 0
    for t in permutations(range(N)):
        max_ = max(max_, eval_(N, regs, t))
    return max_

def main():
    N, M = tuple(map(int, input().split()))
    regs = [[0 for i in range(N)] for j in range(N)]
    for k in range(M):
        i1, i2, score = tuple(map(int, input().split()))
        regs[i1][i2] = score
    print(solve(N, regs))

main()
0