結果

問題 No.3014 岩井満足性問題
ユーザー GOTKAKO
提出日時 2025-01-25 13:04:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 296 ms / 3,000 ms
コード長 666 bytes
コンパイル時間 1,833 ms
コンパイル使用メモリ 199,676 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2025-01-25 22:32:32
合計ジャッジ時間 3,472 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

    int N,D,K; cin >> N >> D >> K;
    vector<int> A(N),C(N);
    for(auto &a : A) cin >> a;
    for(auto &c : C) cin >> c;

    vector<vector<long long>> dp(D+1,vector<long long>(K+1,-1e18));
    dp.at(0).at(0) = 0;
    for(int i=0; i<N; i++){
        int a = A.at(i),c = C.at(i);
        for(int k=D-1; k>=0; k--) for(int l=0; l<=K; l++){
            dp.at(k+1).at(min(K,l+c)) = max(dp.at(k+1).at(min(K,l+c)),dp.at(k).at(l)+a);
        }
    }   
    if(dp.at(D).at(K) <= -1e17) cout << "No" << endl;
    else cout << dp.at(D).at(K) << endl; 
}
0