結果

問題 No.37 遊園地のアトラクション
ユーザー GOTKAKO
提出日時 2025-05-22 19:06:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 494 bytes
コンパイル時間 1,836 ms
コンパイル使用メモリ 195,764 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-22 19:06:49
合計ジャッジ時間 3,278 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T,N; cin >> T >> N;
    vector<int> C(N),V(N);
    for(auto &c : C) cin >> c;
    for(auto &v : V) cin >> v;

    vector<int> dp(T+1); 
    for(int i=0; i<N; i++){
        int c = C.at(i),v = V.at(i);
        while(v){
            for(int k=T-c; k>=0; k--) dp.at(k+c) = max(dp.at(k+c),dp.at(k)+v);
            v /= 2;
        }
    }
    cout << dp.back() << endl;
}
0