結果

問題 No.664 超能力者Aと株価予測
ユーザー 👑 horiesinitihoriesiniti
提出日時 2017-10-13 15:32:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 4,000 ms
コード長 829 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 61,004 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-11 00:20:40
合計ジャッジ時間 1,432 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>

const int LIMITM=20;
const int LIMITN=390;


int main(){
	long long int dp[LIMITM+1][LIMITN+1];
	int n,m,k1;
	scanf("%d %d %d",&n,&m,&k1);
	long long int ans=k1;
	long long int as[LIMITN+1];
	for(int i=0;i<=n;i++){
		int e;
		scanf("%d",&e);
		as[i]=e;
	}
	memset(dp,-1,sizeof(dp));
	dp[0][0]=k1;
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++){
			long long int money=dp[i][j];
			if(money>-1){
				for(int k=j+1;k<=n;k++){
					dp[i][k]=std::max(dp[i][k],money);
					long long int t=money/as[j];
					long long int d=money-as[j]*t;
					long long int money2=d+t*as[k];
					dp[i+1][k]=std::max(dp[i+1][k],money2);
				}
			}
		}
	}
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			ans=std::max(ans,dp[i][j]);
		}
	}	
	std::cout<<ans<<std::endl;
}
0