結果

問題 No.90 品物の並び替え
ユーザー むらため
提出日時 2019-01-19 07:13:24
言語 Nim
(2.2.0)
結果
AC  
実行時間 79 ms / 5,000 ms
コード長 640 bytes
コンパイル時間 2,378 ms
コンパイル使用メモリ 62,200 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-01 10:19:46
合計ジャッジ時間 3,013 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,algorithm
template times*(n:int,body) = (for _ in 0..<n: body)
template `max=`*(x,y) = x = max(x,y)

proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    var k = getchar_unlocked()
    if k < '0' or k > '9': break
    else: result = 10 * result + k.ord - '0'.ord

let n = scan()
let m = scan()
var N = newSeqWith(n,newSeq[int](n))
m.times:
  let (i1,i2,s) = (scan(),scan(),scan())
  N[i1][i2] = s
var p = toSeq(0..<n)
var ans = 0
while p.nextPermutation():
  var x = 0
  for i in 0..<n:
    for j in (i+1)..<n:
      x += N[p[i]][p[j]]
  ans .max= x
echo ans
0