結果
問題 |
No.664 超能力者Aと株価予測
|
ユーザー |
![]() |
提出日時 | 2018-08-13 23:01:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 4,000 ms |
コード長 | 840 bytes |
コンパイル時間 | 999 ms |
コンパイル使用メモリ | 83,000 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 08:21:08 |
合計ジャッジ時間 | 1,696 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <cstdio> #include <cstring> #include <math.h> using namespace std; typedef long long ll; typedef double D; typedef pair<int,int> P; #define M 1000000007 #define F first #define S second #define PB push_back ll n,m,k; ll dp[400][25],a[400],ans; int main(void){ cin>>n>>m>>k; dp[0][m]=k; n++; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n;i++){ for(int j=0;j<=m;j++){ dp[i+1][j]=max(dp[i+1][j],dp[i][j]); if(j==0)continue; ll o=dp[i][j]/a[i]; for(int l=i+1;l<n;l++){ dp[l+1][j-1]=max(dp[l+1][j-1],dp[i][j]+o*(a[l]-a[i])); } } } for(int i=0;i<=m;i++)ans=max(ans,dp[n][i]); cout<<ans; }