結果

問題 No.54 Happy Hallowe'en
ユーザー te-shte-sh
提出日時 2017-02-16 14:32:31
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 1,451 ms / 5,000 ms
コード長 604 bytes
コンパイル時間 1,571 ms
コンパイル使用メモリ 178,332 KB
実行使用メモリ 7,932 KB
最終ジャッジ日時 2023-09-03 01:32:31
合計ジャッジ時間 9,159 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 202 ms
7,380 KB
testcase_05 AC 346 ms
7,876 KB
testcase_06 AC 540 ms
7,924 KB
testcase_07 AC 814 ms
7,928 KB
testcase_08 AC 1,087 ms
7,932 KB
testcase_09 AC 1,447 ms
7,932 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 749 ms
7,924 KB
testcase_13 AC 1,451 ms
7,872 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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 maxV = vti.back.v + vti.back.t;

  auto dp = new bool[](maxV + 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