結果

問題 No.664 超能力者Aと株価予測
ユーザー 0w10w1
提出日時 2018-03-15 14:56:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 4,000 ms
コード長 691 bytes
コンパイル時間 2,286 ms
コンパイル使用メモリ 204,940 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 14:15:31
合計ジャッジ時間 3,205 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template<typename T1, typename T2>
void upmax(T1 &x, T2 v) {
  if (x < v) x = v;
}

signed main() {
  ios::sync_with_stdio(false);
  int N, M, K;
  cin >> N >> M >> K;
  vector<int> A(N + 1);
  for (int i = 0; i < N + 1; ++i) cin >> A[i];
  vector<vector<int64_t>> d(N + 1, vector<int64_t>(M + 1));
  d[0][0] = K;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= M; ++j) {
      upmax(d[i][j], d[i - 1][j]);
      if (j) {
        for (int k = 0; k < i; ++k) {
          upmax(d[i][j], d[k][j - 1] % A[k] + d[k][j - 1] / A[k] * A[i]);
        }
      }
    }
  }
  cout << *max_element(d[N].begin(), d[N].end()) << endl;
  return 0;
}
0