結果

問題 No.3014 岩井満足性問題
ユーザー takoyaki782
提出日時 2025-07-14 15:34:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 1,438 bytes
コンパイル時間 4,156 ms
コンパイル使用メモリ 258,004 KB
実行使用メモリ 814,592 KB
最終ジャッジ日時 2025-07-14 15:34:26
合計ジャッジ時間 9,066 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 MLE * 2 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll inf_ll = 9223372036854775807;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using mint = atcoder::modint998244353;
using mint1 = atcoder::modint1000000007;
using Pa = std::pair<ll, ll>;

int Yes(bool x){
    if(x) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

int main(){
    ll N, D, K;
    cin >> N >> D >> K;
    vector<ll> A(N), C(N);
    rep(i, N){
        cin >> A[i];
    }
    rep(i, N){
        cin >> C[i];
    }
    vector<vector<vector<ll>>> dp(N+1, vector<vector<ll>>(D+1, vector<ll>(K+1, -1e18)));
    dp[0][0][0] = 0;
    rep(i, N){
        rep(j, D+1){
            rep(k, K+1){
                if(dp[i][j][k] == -1e18) continue;
                chmax(dp[i+1][j][k], dp[i][j][k]);
                if(j == D) continue;
                if(C[i]+k >= K){
                    chmax(dp[i+1][j+1][K], dp[i][j][k]+A[i]);
                }
                else{
                    chmax(dp[i+1][j+1][C[i]+k], dp[i][j][k]+A[i]);
                }
            }
        }
    }
    if(dp[N][D][K] == -1e18){
        cout << "No";
    }
    else{
        cout << dp[N][D][K];
    }
}
0