結果
| 問題 |
No.664 超能力者Aと株価予測
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2017-10-13 15:32:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 4,000 ms |
| コード長 | 829 bytes |
| コンパイル時間 | 1,383 ms |
| コンパイル使用メモリ | 57,948 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 11:24:45 |
| 合計ジャッジ時間 | 1,275 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d %d %d",&n,&m,&k1);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d",&e);
| ~~~~~^~~~~~~~~
ソースコード
#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;
}
horiesiniti