結果

問題 No.3014 岩井満足性問題
コンテスト
ユーザー anchuyu
提出日時 2026-01-03 00:32:47
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
MLE  
実行時間 -
コード長 1,017 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,066 ms
コンパイル使用メモリ 221,852 KB
実行使用メモリ 814,592 KB
最終ジャッジ日時 2026-01-03 00:32:53
合計ジャッジ時間 5,726 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 MLE * 2 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

vector<vector<vector<long long>>> make_3Dvec(int i, int j, int k, long long init){
  return vector<vector<vector<long long>>>(
    i, vector<vector<long long>>(j, vector<long long>(k, init))
  );
}

int main () {
  int n, d, k;
  cin >> n >> d >> k;

  vector<long long> a(n), c(n);
  for (auto &el : a) cin >> el;
  for (auto &el : c) cin >> el;

  const long long NEG = -(1LL << 60);
  
  auto dp = make_3Dvec(n + 1, d + 1, k + 1, NEG);
  dp[0][0][0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= d; j++) {
      for (int l = 0; l <= k; l++) {
        long long now = dp[i][j][l];
        if (now == NEG) continue;

        dp[i + 1][j][l] = max(dp[i + 1][j][l], now);

        if (j < d) {
          int nl = min(k, (int)(l + c[i]));
          dp[i + 1][j + 1][nl] =
              max(dp[i + 1][j + 1][nl], now + a[i]);
        }
      }
    }
  }

  long long ans = dp[n][d][k];
  if (ans == NEG) cout << "No" << endl;
  else cout << ans << endl;
}
0