結果

問題 No.90 品物の並び替え
ユーザー 6soukiti296soukiti29
提出日時 2017-08-16 16:55:37
言語 Nim
(2.0.2)
結果
AC  
実行時間 487 ms / 5,000 ms
コード長 699 bytes
コンパイル時間 3,071 ms
コンパイル使用メモリ 68,456 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 14:42:20
合計ジャッジ時間 4,538 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 36 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 41 ms
4,380 KB
testcase_06 AC 30 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 487 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 36) Warning: imported and not used: 'math' [UnusedImport]

ソースコード

diff #

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 index[T](A : openarray[T], a:T) : int =
    for i in 0..A.high:
        if A[i] == a:
            return i
    return -1


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

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

echo ans
0