結果
問題 | No.3014 岩井満足性問題 |
ユーザー |
|
提出日時 | 2025-01-26 00:07:03 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 107 ms / 3,000 ms |
コード長 | 861 bytes |
コンパイル時間 | 3,517 ms |
コンパイル使用メモリ | 279,816 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-26 00:07:19 |
合計ジャッジ時間 | 4,331 ms |
ジャッジサーバーID (参考情報) |
judge7 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;#define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i)#define all(a) (a).begin(), (a).end()ll const INF = 1ll << 60;int main() {cin.tie(nullptr);std::ios_base::sync_with_stdio(false);int N, D, K;cin >> N >> D >> K;vector<int> A(N), C(N);rep(i, 0, N) cin >> A[i];rep(i, 0, N) cin >> C[i];vector dp(D + 1, vector<ll>(K + 1, -INF));dp[0][0] = 0;rep(t, 0, N) {for (int i = D - 1; i >= 0; --i) {for (int j = K; j >= 0; --j) {if (dp[i][j] == -INF) continue;dp[i + 1][min(j + C[t], K)] = max(dp[i + 1][min(j + C[t], K)], dp[i][j] + A[t]);}}}if (dp[D][K] == -INF) cout << "No\n";else cout << dp[D][K] << '\n';}