結果
問題 | No.90 品物の並び替え |
ユーザー |
![]() |
提出日時 | 2019-01-06 07:07:38 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 426 ms / 5,000 ms |
コード長 | 889 bytes |
コンパイル時間 | 2,961 ms |
コンパイル使用メモリ | 65,172 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 06:24:56 |
合計ジャッジ時間 | 4,081 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
import strutilsproc nextString: string =result = ""while not endOfFile stdin:let nextChar = readChar stdincase nextCharof '\r':discardof "\n"[0], ' ':breakelse:add result, nextCharproc nextInt: int =parseInt nextString()letn, m = nextInt()varscoreList = newSeq[tuple[item1, item2, score: int]](m)ans = 0proc 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].scoreproc dfs(items: seq[int], score: int) =if items.len == n:ans = max(ans, score)returnfor i in 0 ..< n:if i notin items:dfs(items & i, score + calcScore(items, i))proc main: void =for i in 0 ..< m:scoreList[i] = (nextInt(), nextInt(), nextInt())dfs(@[], 0)echo answhen isMainModule:main()