結果
| 問題 |
No.37 遊園地のアトラクション
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2014-11-24 02:42:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 851 bytes |
| コンパイル時間 | 282 ms |
| コンパイル使用メモリ | 35,168 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-10 12:50:09 |
| 合計ジャッジ時間 | 1,139 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d %d", &T, &N);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:11:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | for(int i=0;i<N;i++){scanf("%d", C+i);}
| ~~~~~^~~~~~~~~~~
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d", &V[i][1]);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <algorithm>
int T, N;
int dp[16][10001];
int C[15], V[15][10];
int main(){
scanf("%d %d", &T, &N);
for(int i=0;i<N;i++){scanf("%d", C+i);}
for(int i=0;i<N;i++){
scanf("%d", &V[i][1]);
for(int j=1;j<10;j++){
V[i][j] += V[i][j-1] / 2;
}
for(int j=1;j<10;j++){
V[i][j] += V[i][j-1];
}
}
std::fill(&dp[0][0], &dp[0][0]+16*10001, -1001001001);
dp[0][0] = 0;
for(int i=1;i<=N;i++){
for(int j=0;j<=T;j++){
if(j > 0){dp[i][j] = dp[i][j-1];}
for(int k=0;k<10;k++){
if(j-C[i-1]*k >= 0){
dp[i][j] = std::max(dp[i][j], dp[i-1][j-C[i-1]*k] + V[i-1][k]);
}
}
}
}
printf("%d\n", dp[N][T]);
}
tottoripaper