結果

問題 No.710 チーム戦
ユーザー te-shte-sh
提出日時 2018-07-03 13:43:06
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 49 ms / 3,000 ms
コード長 822 bytes
コンパイル時間 776 ms
コンパイル使用メモリ 92,112 KB
実行使用メモリ 43,412 KB
最終ジャッジ日時 2023-09-03 20:29:52
合計ジャッジ時間 2,585 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 28 ms
22,596 KB
testcase_03 AC 27 ms
22,336 KB
testcase_04 AC 30 ms
23,600 KB
testcase_05 AC 26 ms
22,288 KB
testcase_06 AC 28 ms
22,580 KB
testcase_07 AC 28 ms
22,804 KB
testcase_08 AC 30 ms
24,128 KB
testcase_09 AC 28 ms
22,856 KB
testcase_10 AC 26 ms
21,108 KB
testcase_11 AC 27 ms
22,336 KB
testcase_12 AC 30 ms
23,596 KB
testcase_13 AC 29 ms
23,040 KB
testcase_14 AC 29 ms
23,036 KB
testcase_15 AC 26 ms
21,992 KB
testcase_16 AC 30 ms
23,588 KB
testcase_17 AC 25 ms
21,100 KB
testcase_18 AC 30 ms
23,380 KB
testcase_19 AC 30 ms
23,712 KB
testcase_20 AC 27 ms
22,360 KB
testcase_21 AC 29 ms
23,084 KB
testcase_22 AC 49 ms
43,412 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 48 ms
40,672 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n; readV(n);
  int[] a, b; readC(n, a, b);

  auto sa = a.sum, dp = new int[][](n+1, sa+1);
  foreach (i; 0..n+1) dp[i][] = 10^^6;
  dp[0][0] = 0;

  foreach (i; 0..n)
    foreach (t; 0..sa+1) {
      dp[i+1][t] = dp[i][t]+b[i];
      if (t >= a[i])
        dp[i+1][t] = min(dp[i+1][t], dp[i][t-a[i]]);
    }

  auto r = 10^^6;
  foreach (t; 0..sa+1)
    r = min(r, max(t, dp[n][t]));

  writeln(r);
}
0