結果

問題 No.37 遊園地のアトラクション
ユーザー なおなお
提出日時 2014-10-09 23:52:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 916 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 61,676 KB
実行使用メモリ 9,760 KB
最終ジャッジ日時 2023-08-28 20:36:19
合計ジャッジ時間 2,160 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,580 KB
testcase_01 AC 4 ms
9,584 KB
testcase_02 AC 3 ms
9,616 KB
testcase_03 AC 3 ms
9,552 KB
testcase_04 AC 4 ms
9,600 KB
testcase_05 AC 3 ms
9,568 KB
testcase_06 AC 4 ms
9,572 KB
testcase_07 AC 4 ms
9,616 KB
testcase_08 AC 3 ms
9,704 KB
testcase_09 AC 3 ms
9,636 KB
testcase_10 AC 4 ms
9,732 KB
testcase_11 AC 4 ms
9,636 KB
testcase_12 AC 4 ms
9,604 KB
testcase_13 AC 3 ms
9,612 KB
testcase_14 AC 4 ms
9,572 KB
testcase_15 WA -
testcase_16 AC 4 ms
9,728 KB
testcase_17 AC 3 ms
9,576 KB
testcase_18 AC 4 ms
9,728 KB
testcase_19 AC 3 ms
9,640 KB
testcase_20 AC 4 ms
9,596 KB
testcase_21 AC 4 ms
9,760 KB
testcase_22 AC 4 ms
9,732 KB
testcase_23 AC 3 ms
9,596 KB
testcase_24 AC 3 ms
9,696 KB
testcase_25 AC 4 ms
9,668 KB
testcase_26 AC 3 ms
9,604 KB
testcase_27 WA -
testcase_28 AC 3 ms
9,648 KB
testcase_29 AC 4 ms
9,600 KB
testcase_30 AC 3 ms
9,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))

int T, N, C[16], V;
int dp[160][10010];
int main(){
    cin >> T >> N;
    REP(i,N) cin >> C[i];
    vector<pair<int,int> >v;
    REP(i,N){
        cin >> V;
        while(V){
            v.push_back(make_pair(V,C[i]));
            V /= 2;
        }
    }

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;

    int s = v.size();
    int maxv = 0;
    REP(i,s){
        int k = v[i].first, c = v[i].second;
        REP(j,T){
            if(dp[i][j] < 0) continue;
            if(j + c <= T){
                dp[i+1][j+c] = max(dp[i+1][j+c], dp[i][j] + k);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    REP(j,T+1) maxv = max(maxv, dp[s][j]);
    cout << maxv << endl;
    return 0;
}
0