結果

問題 No.664 超能力者Aと株価予測
ユーザー te-shte-sh
提出日時 2018-04-16 16:48:26
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 21 ms / 4,000 ms
コード長 776 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 92,128 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-03 19:35:54
合計ジャッジ時間 1,554 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

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

void main()
{
  int n, m, k; readV(n, m, k);
  int[] a; readC(n+1, a);

  auto dp = new long[][](n+1, m+1);
  dp[0][0] = k;
  foreach (i; 0..n)
    foreach (j; 0..m+1) {
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      if (j < m)
        foreach (i2; i+1..n+1)
          dp[i2][j+1] = max(dp[i2][j+1], dp[i][j]/a[i]*a[i2]+dp[i][j]%a[i]);
    }

  writeln(dp[$-1].maxElement);
}
0