結果

問題 No.90 品物の並び替え
ユーザー むらためむらため
提出日時 2019-01-19 07:13:24
言語 Nim
(2.0.2)
結果
AC  
実行時間 92 ms / 5,000 ms
コード長 640 bytes
コンパイル時間 2,433 ms
コンパイル使用メモリ 69,344 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 02:15:36
合計ジャッジ時間 3,277 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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