結果

問題 No.664 超能力者Aと株価予測
ユーザー ei1333333ei1333333
提出日時 2018-03-10 00:28:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 4,000 ms
コード長 622 bytes
コンパイル時間 2,008 ms
コンパイル使用メモリ 198,444 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 06:10:00
合計ジャッジ時間 2,683 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 60;

int main() {
  int64 N, M, K, A[391];

  cin >> N >> M >> K;
  ++N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }

  vector< int64 > dp(N + 1, K);

  for(int i = 0; i < M; i++) {
    vector< int64 > dp2(dp);
    for(int j = 0; j < N; j++) {
      int64 sm = A[j];
      for(int k = j + 1; k < N; k++) {
        int64 sz = dp[j] / sm;
        dp2[k + 1] = max(dp2[k + 1], dp[j] % sm + sz * A[k]);
        sm = min(sm, A[k]);
      }
    }
    dp.swap(dp2);
  }

  cout << *max_element(begin(dp), end(dp)) << endl;
}
0