結果

問題 No.37 遊園地のアトラクション
ユーザー nebukuro09nebukuro09
提出日時 2016-11-17 13:28:52
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 713 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 99,328 KB
実行使用メモリ 264,600 KB
最終ジャッジ日時 2023-09-02 22:56:28
合計ジャッジ時間 7,459 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,368 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
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 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int T, N;
int[] C, V;
int[long] mem;

int rec(long b, int t, int acm) {
  if (b in mem)
    return mem[b];

  mem[b] = acm;
  foreach (i; iota(N)) {
    auto b2 = b / 10^^i % 10;
    if (t > C[i] && (V[i] >> b2) > 0 &&  b2 < 9)
      mem[b] = max(mem[b], rec(b+(b2+1)*(10^^i), t-C[i], acm+(V[i]>>b2)));
  }
  return mem[b];
}

void main() {
  T = readln.chomp.to!int;
  N = readln.chomp.to!int;
  C = readln.split.map!(to!int).array;
  V = readln.split.map!(to!int).array;
  writeln(rec(0L, T, 0));
}
0