結果
| 問題 |
No.3014 岩井満足性問題
|
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2025-01-25 13:17:43 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 692 ms / 3,000 ms |
| コード長 | 1,130 bytes |
| コンパイル時間 | 1,048 ms |
| コンパイル使用メモリ | 106,608 KB |
| 実行使用メモリ | 7,072 KB |
| 最終ジャッジ日時 | 2025-01-25 22:41:28 |
| 合計ジャッジ時間 | 4,258 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long INF = 1e18;
int main() {
int N, D, K;
cin >> N >> D >> K;
vector<long long> 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<long long>> dp(D + 1, vector<long long>(K + 1, -INF));
dp[0][0] = 0;
for (int i = 0; i < N; ++i) {
vector<vector<long long>> ndp(D + 1, vector<long long>(K + 1, -INF));
for (int j = 0; j <= D; ++j) {
for (int k = 0; k <= K; ++k) {
if (dp[j][k] == -INF) continue;
// Don't take this item
ndp[j][k] = max(ndp[j][k], dp[j][k]);
// Take this item if possible
if (j < D) {
int new_k = min(k + C[i], (long long)K);
ndp[j + 1][new_k] = max(ndp[j + 1][new_k], dp[j][k] + A[i]);
}
}
}
dp = ndp;
}
if (dp[D][K] != -INF) {
cout << dp[D][K] << endl;
} else {
cout << "No" << endl;
}
return 0;
}
detteiuu