結果

問題 No.37 遊園地のアトラクション
ユーザー tottoripapertottoripaper
提出日時 2014-11-24 02:40:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 898 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 35,292 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 19:28:16
合計ジャッジ時間 1,260 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]);
      |         ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

#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++){
            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]);
                }
            }
        }
    }

    int res = 0;
    for(int i=0;i<=T;i++){
            res = std::max(res, dp[N][i]);
    }

    printf("%d\n", res);
}
0