結果

問題 No.37 遊園地のアトラクション
ユーザー koyoprokoyopro
提出日時 2015-09-29 21:53:26
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 686 bytes
コンパイル時間 1,652 ms
コンパイル使用メモリ 146,928 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-27 00:23:57
合計ジャッジ時間 6,036 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)

int T, N;
struct A { int c, v; };
vector<A> a;
int main()
{
    cin>>T>>N;
    REP(i,N) {
        A ai = A();
        cin >> ai.c;
        a.push_back(ai);
    }
    REP(i,N) cin >> a[i].v;
    int dp[10001] = {0};
    REP(i,N) {
        A ai = a[i];
        int v = ai.v;
        int c = ai.c;
        while(v > 0) {
            RREP(j,10001) {
                dp[j+c] = max(dp[j+c], dp[j] + v);
            }
            v /= 2;
        }
    }
    int maxc = 0;
    REP(i,T+1) maxc = max(maxc, dp[i]);
    cout << maxc << endl;

    return 0;
}
0