結果

問題 No.90 品物の並び替え
コンテスト
ユーザー 6soukiti29
提出日時 2017-08-16 17:06:35
言語 Nim
(2.2.8)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 738 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 653 ms
コンパイル使用メモリ 65,408 KB
最終ジャッジ日時 2026-03-19 19:57:40
合計ジャッジ時間 1,004 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(8, 33) Error: tuple expected for tuple unpacking, but got 'seq[int]'

ソースコード

diff #
raw source code

import sequtils,strutils,algorithm,math

type
    item = tuple[a, b, score : int]
var
    N,M,a,b,c : int
    p : item
(N,M) = stdin.readline.split.map(parseInt)
var
    Items = newSeq[item](0)
    nodes = newSeq[int](N)
    ans : int
    
for n in 0..<N:
    nodes[n] = n
for m in 1..M:
    (a,b,c) = stdin.readline.split.map(parseInt)
    Items.add((a,b,c))
proc precedence[T](A : openarray[T]; a,b:T) : bool =
    for p in A:
        if p == a:
            return true
        elif p == b:
            return false
    return false


proc sum_score(): int =
    for t in Items:
        if nodes.precedence(t.a,t.b):
            result += t.score

ans = sum_score()
while nodes.nextPermutation:
    ans = max(sum_score(), ans)

echo ans
0