結果

問題 No.664 超能力者Aと株価予測
ユーザー beetbeet
提出日時 2018-03-09 22:33:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 20 ms / 4,000 ms
コード長 1,392 bytes
コンパイル時間 1,460 ms
コンパイル使用メモリ 163,552 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 12:21:01
合計ジャッジ時間 2,150 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m,k;
  cin>>n>>m>>k;
  n++;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  auto dp=make_v<Int>(n,m+1);
  fill_v(dp,-1);
  dp[0][0]=k;
  for(Int i=0;i<n;i++){
    for(Int j=m;j>=0;j--){
      if(dp[i][j]<0) continue;
      for(Int k=i+1;k<n;k++){
	chmax(dp[k][j],dp[i][j]);
	if(j==m) continue;
	//cout<<i<<" "<<j<<" "<<k<<":"<<(a[k]-a[i])<<" "<<(dp[i][j]/a[i])<<endl;
	chmax(dp[k][j+1],dp[i][j]+(a[k]-a[i])*(dp[i][j]/a[i]));
      }
    }
  }
  Int ans=k;
  for(Int j=0;j<=m;j++) chmax(ans,dp[n-1][j]);
  cout<<ans<<endl;
  return 0;
}
0