結果

問題 No.664 超能力者Aと株価予測
ユーザー nxterunxteru
提出日時 2018-08-13 23:01:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 4,000 ms
コード長 840 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 82,908 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 16:51:14
合計ジャッジ時間 1,246 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0