結果
問題 | No.3014 岩井満足性問題 |
ユーザー |
|
提出日時 | 2025-01-25 12:38:43 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 544 ms / 3,000 ms |
コード長 | 1,040 bytes |
コンパイル時間 | 4,480 ms |
コンパイル使用メモリ | 282,416 KB |
実行使用メモリ | 7,208 KB |
最終ジャッジ日時 | 2025-01-25 22:07:00 |
合計ジャッジ時間 | 7,263 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge8 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef local#include <debug.hpp>#else#define debug(...)#endif#define rep(i, n) for (int i = 0; i < n; i++)template <class T> istream& operator>>(istream& I, vector<T>& V) {for (T& X : V) I >> X; return I;}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;}vector<int> di = {-1, 1, 0, 0}, dj = {0, 0, -1, 1}; int inf = 2e9; long INF = 1e18;int main() {int n, d, k;cin >> n >> d >> k;vector<int> a(n), c(n);cin >> a >> c;vector dp(d + 1, vector<long>(k + 1, -INF));dp[0][0] = 0;rep(i, n) {auto p = dp;swap(p, dp);rep(j, d) rep(I, k + 1) {int nk = min(k, I + c[i]);chmax(dp[j + 1][nk], p[j][I] + a[i]);}}long ans = dp[d][k];if (ans < -1e10) {cout << "No\n";} else {cout << ans << endl;}return 0;}