結果

問題 No.90 品物の並び替え
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2019-01-06 10:08:38
言語 Nim
(2.0.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 950 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 65,184 KB
最終ジャッジ日時 2024-04-27 02:45:53
合計ジャッジ時間 1,183 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(40, 15) Error: undeclared identifier: 'lc'

ソースコード

diff #

import sugar, strutils
from algorithm import nextpermutation


proc nextString: string =
  result = ""
  while not endOfFile stdin:
    let nextChar = readChar stdin
    case nextChar
    of '\r':
      discard
    of "\n"[0], ' ':
      break
    else:
      add result, nextChar


proc nextInt: int =
  parseInt nextString()


let
  n, m = nextInt()

var
  scoreList = newSeq[tuple[item1, item2, score: int]](m)
  ans = 0


proc calcScore(items: seq[int], x: int): int =
  for i in 0 ..< m:
    if x == scoreList[i].item2 and scoreList[i].item1 in items:
      result += scoreList[i].score


proc main: void =
  for i in 0 ..< m:
    scoreList[i] = (nextInt(), nextInt(), nextInt())

  var items = lc[j | (j <- 0 ..< n), int]

  while true:
    var score = 0
    for j in 0 ..< n:
      score += calcScore(items[0 ..< j], items[j])

    ans = max(ans, score)

    if not items.nextPermutation:
      break

  echo ans


when isMainModule:
  main()
0