結果
問題 |
No.664 超能力者Aと株価予測
|
ユーザー |
|
提出日時 | 2025-09-24 20:32:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 4,000 ms |
コード長 | 618 bytes |
コンパイル時間 | 2,022 ms |
コンパイル使用メモリ | 194,620 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-24 20:32:33 |
合計ジャッジ時間 | 3,248 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long const int N=400,M=30; int n,m,k,a[N]; int f[N][M]; inline int calc(int x,int p,int q){ if(p>=q) return x; int t=x/p; return x+t*(q-p); } signed main(){ //freopen("stock.in","r",stdin); //freopen("stock.out","w",stdout); cin>>n>>m>>k;++n; for(int i=1;i<=n;i++) cin>>a[i]; f[0][0]=k; a[0]=1e18; int ans=0; for(int t=1;t<=m;t++){ for(int i=t;i<=n;i++){ int mn=a[i-1]; for(int j=i-1;j>=t-1;j--){ mn=min(mn,a[j]); f[i][t]=max(f[i][t],calc(f[j][t-1],mn,a[i])); } ans=max(ans,f[i][t]); } } cout<<ans<<'\n'; return 0; }