結果
問題 | No.664 超能力者Aと株価予測 |
ユーザー |
![]() |
提出日時 | 2016-07-04 10:59:50 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 122 ms / 4,000 ms |
コード長 | 912 bytes |
コンパイル時間 | 608 ms |
コンパイル使用メモリ | 70,420 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 20:05:33 |
合計ジャッジ時間 | 1,614 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d %d %d",&n,&m,&k1); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%d",&e); | ~~~~~^~~~~~~~~
ソースコード
#include<stdio.h>#include<map>#include<algorithm>#include<iostream>const int LIMITM=20;const int LIMITN=390;int main(){std::map<int,long long int> dp[LIMITM+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;}for(int i=0;i<m;i++){long long int money=k1;for(int j=0;j<=n;j++){for(int k=j+1;k<=n;k++){if(as[j]<as[k]){long long int t=money/as[j];long long int d=money-as[j]*t;long long int u=d+t*as[k];if(dp[i+1].find(k)==dp[i+1].end()){dp[i+1][k]=u;}else{dp[i+1][k]=std::max(u,dp[i+1][k]);}}}if(dp[i].find(j)!=dp[i].end()){money=std::max(dp[i][j],money);}if(dp[i+1].find(j)!=dp[i+1].end()){ans=std::max(ans,dp[i+1][j]);}}}std::cout<<ans<<std::endl;}