結果

問題 No.37 遊園地のアトラクション
コンテスト
ユーザー koyopro
提出日時 2015-09-29 21:53:26
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 686 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,045 ms
コンパイル使用メモリ 180,884 KB
実行使用メモリ 188,856 KB
最終ジャッジ日時 2026-04-02 17:43:27
合計ジャッジ時間 4,258 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 11 RE * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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