結果

問題 No.664 超能力者Aと株価予測
ユーザー fura
提出日時 2020-08-03 20:08:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 19 ms / 4,000 ms
コード長 552 bytes
コンパイル時間 2,176 ms
コンパイル使用メモリ 198,700 KB
最終ジャッジ日時 2025-01-12 13:50:25
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         int n,m,x0; scanf("%d%d%d",&n,&m,&x0);
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:13:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         rep(i,n+1) scanf("%d",&a[i]);
      |                    ~~~~~^~~~~~~~~~~~

ソースコード

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