結果

問題 No.37 遊園地のアトラクション
ユーザー nebukuro09
提出日時 2016-11-22 17:00:58
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 582 bytes
コンパイル時間 971 ms
コンパイル使用メモリ 110,252 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 05:10:58
合計ジャッジ時間 2,718 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

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;


void main() {
  auto T = readln.chomp.to!int;
  auto N = readln.chomp.to!int;
  auto C = readln.split.map!(to!int);
  auto V = readln.split.map!(to!int);

  auto dp = new int[](T+1);
  foreach (i; 0..N)
    foreach (j; 0..10)
      foreach (t; iota(T, -1, -1))
        if (t-C[i] >= 0 && t <= T)
          dp[t] = max(dp[t], dp[t-C[i]]+(V[i]>>j));

  writeln(dp[T]);
}
0