#include #include #include using namespace std; const long long INF = 1e18; int main() { int N, D, K; cin >> N >> D >> K; vector 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> dp(D + 1, vector(K + 1, -INF)); dp[0][0] = 0; for (int i = 0; i < N; ++i) { vector> ndp(D + 1, vector(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; }