結果

問題 No.664 超能力者Aと株価予測
ユーザー どららどらら
提出日時 2018-03-10 10:22:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 4,000 ms
コード長 854 bytes
コンパイル時間 1,508 ms
コンパイル使用メモリ 167,608 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 23:28:02
合計ジャッジ時間 2,134 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


ll dp[400][25];

int main(){
  int N, M;
  ll K;
  cin >> N >> M >> K;
  vector<ll> v;
  rep(i,N+1){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  rep(i,v.size()+1){
    dp[i][0] = K;
  }

  ll ret = K;
  REP(i,1,M+1){
    rep(j,v.size()){
      if(j>0) dp[j][i] = max(dp[j][i], dp[j-1][i]);
      rep(k,j){
        ll money = dp[k][i-1];
        ll a = money/v[k];
        ll b = money - v[k]*a;
        ll c = b+v[j]*a;
        dp[j][i] = max(dp[j][i], c);
      }
      ret = max(ret, dp[j][i]);
    }
  }

  cout << ret << endl;
  return 0;
}
0