結果

問題 No.37 遊園地のアトラクション
ユーザー fantasiabaeticafantasiabaetica
提出日時 2018-10-10 19:49:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,047 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 65,008 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 19:28:31
合計ジャッジ時間 6,524 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<(b); i++)

int T, N;
// 待ち時間, 満足度
int c[15], v[15];
int dp[10001][15];

// 残り時間tのとき、n番目以降の乗り物に乗った時に得られる最大の満足度を返す
int dfs(int t, int n){
    if (n == N) return 0;
    if (dp[t][n] != -1) return dp[t][n];
    int max = 0;
    int tmp = 0;
    // n番目の乗り物に乗って得られる満足度。vnはループを回すたびに半減。
    int vn_sum = 0;
    int vn = v[n];
    for(int i = 0; i * c[n] <= t; i++){
        tmp += dfs(t - i * c[n], n + 1) + vn_sum;
        if (tmp > max) max = tmp;
        vn_sum += vn;
        vn /= 2;
    }
    dp[t][n] = max;
    return max;
}

int main(){
    cin >> T >> N;
    FOR(i, 0, N) cin >> c[i];
    FOR(i, 0, N) cin >> v[i];
    FOR(i, 0, 10001){
        FOR(j, 0, 15) dp[i][j] = -1;
    }
    cout << dfs(T, 0) << endl;
    FOR(i, 0, T + 1){
        FOR(j, 0, N) cout << dp[i][j] << " ";
        cout << endl;
    }
    return 0;
}
0