結果

問題 No.54 Happy Hallowe'en
ユーザー te-shte-sh
提出日時 2017-02-16 14:28:43
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 598 bytes
コンパイル時間 1,547 ms
コンパイル使用メモリ 181,324 KB
実行使用メモリ 60,240 KB
最終ジャッジ日時 2023-09-03 01:32:17
合計ジャッジ時間 8,278 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto vti = n.iota.map!(_ => readln.split.to!(int[])).map!(rd => VT(rd[0], rd[1])).array;
  vti.sort!"a.v + a.t < b.v + b.t";

  auto sumV = vti.map!"a.v".sum;

  auto dp = new bool[](sumV + 1);
  dp[0] = true;

  foreach (i; n.iota) {
    auto dp2 = chain(repeat(false).take(vti[i].v), dp.dup.take(vti[i].t), repeat(false));
    foreach (ref d1, d2; lockstep(dp, dp2))
      d1 = d1 | d2;
  }

  writeln(dp.enumerate.filter!"a.value".array.back.index);
}

struct VT { int v, t; }
0