#include #include #include using namespace std; // #include // using namespace atcoder; // using mint = modint998244353; using ll = long long; #define fix(x) fixed << setprecision(x) #define rep(i, n) for(int i = 0; i < n; ++i) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> n >> d >> x; vector dp(d+1, vector(x+1,-INFLL)); dp[0][0] = 0; vector a(n), c(n); rep(i,n) cin >> a[i]; rep(i,n) cin >> c[i]; rep(i,n){ for(int j=min(i,d-1);j>=0;--j)for(int k=x;k>=0;--k){ if(dp[j][k]==-INFLL) continue; chmax(dp[j+1][min(x,k+c[i])], dp[j][k]+a[i]); } } if(dp[d][x]==-INFLL) cout << "No\n"; else cout << dp[d][x] << '\n'; return 0; }