結果

問題 No.3014 岩井満足性問題
ユーザー shingo0909
提出日時 2025-01-25 13:39:29
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 732 ms / 3,000 ms
コード長 786 bytes
コンパイル時間 3,455 ms
コンパイル使用メモリ 286,264 KB
実行使用メモリ 7,080 KB
最終ジャッジ日時 2025-01-25 22:54:02
合計ジャッジ時間 6,642 ms
ジャッジサーバーID
(参考情報)
judge9 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;

int main(){
    int n,d,k;
    cin >> n >> d >> k;
    vector<ll>a(n),c(n);
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<n;i++)cin >> c[i];
    vector<vector<ll>>dp (d+1,
    vector<ll>(k+1,-(1LL<<60)));
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        auto ep = dp;
        for(int j=0;j<=d;j++){
            for(int l=0;l<=k;l++){
                if(dp[j][l]==-(1LL<<60))continue;
                if(j==d)continue;
                ep[j+1][min(ll(k),l+c[i])] =max(ep[j+1][min(ll(k),l+c[i])],dp[j][l]+a[i]);
            }
        }
        dp = ep;
    }
    if(dp[d][k] == -(1LL<<60)){
        cout << "No" << endl;
    }else cout << dp[d][k] << endl;
    return 0;
}
0