結果

問題 No.664 超能力者Aと株価予測
ユーザー furafura
提出日時 2020-08-03 20:08:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 4,000 ms
コード長 552 bytes
コンパイル時間 2,185 ms
コンパイル使用メモリ 204,228 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 16:13:22
合計ジャッジ時間 3,492 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int main(){
	int n,m,x0; scanf("%d%d%d",&n,&m,&x0);
	vector<int> a(n+1);
	rep(i,n+1) scanf("%d",&a[i]);

	vector dp(n+1,vector(m+1,-INF));
	dp[0][0]=x0;
	for(int i=1;i<=n;i++) rep(j,m+1) {
		dp[i][j]=dp[i-1][j];
		if(j>0){
			rep(k,i){
				dp[i][j]=max(dp[i][j],dp[k][j-1]%a[k]+dp[k][j-1]/a[k]*a[i]);
			}
		}
	}

	lint ans=x0;
	rep(i,n+1) rep(j,m+1) ans=max(ans,dp[i][j]);
	printf("%lld\n",ans);

	return 0;
}
0