結果

問題 No.90 品物の並び替え
ユーザー te-shte-sh
提出日時 2016-08-30 10:25:16
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 627 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 111,496 KB
実行使用メモリ 4,496 KB
最終ジャッジ日時 2023-09-02 21:35:05
合計ジャッジ時間 3,462 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import std.algorithm, std.array, std.container, std.range;
import std.string, std.conv, std.bigint, std.math, std.random;
import std.stdio, std.typecons;

alias Tuple!(int, "i1", int, "i2", int, "sc") row;

void main()
{
  auto rd = readln.split.map!(to!int);
  auto n = rd[0];
  auto m = rd[1];
  auto tbl = iota(m).map!((_) {
    auto rd = readln.split.map!(to!int);
    return row(rd[0] - 1, rd[1] - 1, rd[2]);
  }).array;

  auto max = 0;
  foreach (ai; iota(n).permutations) {
    auto r = tbl.map!(row => ai.find(row.i1).length > ai.find(row.i2).length ? row.sc : 0).sum;
    if (r > max) max = r;
  }

  writeln(max);
}
0