結果

問題 No.90 品物の並び替え
ユーザー LaLa
提出日時 2020-11-24 22:45:07
言語 Ruby
(3.3.0)
結果
AC  
実行時間 2,496 ms / 5,000 ms
コード長 343 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 11,208 KB
実行使用メモリ 15,420 KB
最終ジャッジ日時 2023-10-01 01:17:05
合計ジャッジ時間 5,590 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,088 KB
testcase_01 AC 305 ms
15,312 KB
testcase_02 AC 83 ms
15,256 KB
testcase_03 AC 111 ms
15,304 KB
testcase_04 AC 107 ms
15,164 KB
testcase_05 AC 306 ms
15,420 KB
testcase_06 AC 304 ms
15,316 KB
testcase_07 AC 87 ms
15,308 KB
testcase_08 AC 82 ms
15,176 KB
testcase_09 AC 2,496 ms
15,256 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N,M=gets.split.map(&:to_i)

S=Array.new(N).map{Array.new(N,0)}
M.times do
    i1,i2,s=gets.split.map(&:to_i)
    S[i1][i2]=s
end

ans=0
(0...N).to_a.permutation do |p|
    cnt=0
    for i in 0...N-1 do
        for j in i+1...N do
            break if j>=N
            cnt+=S[p[i]][p[j]]
        end
    end
    ans=cnt if ans<cnt
end

puts ans
0