#include using namespace std; using ll = long long; using ld = long double; //using ar2 = array; #define pb push_back #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define pop_cnt(s) ll(popcount(uint64_t(s))) #define next_p(v) next_permutation(v.begin(), v.end()) template inline bool chmin(T& a, const T& b) {bool c=a>b; if(a>b) a=b; return c;} template inline bool chmax(T& a, const T& b) {bool c=a inline T gcd(T a,T b) {return (b==0)?a:gcd(b,a%b);} template inline T lcm(T a, T b) {return (a*b)/gcd(a,b);} template using vc = vector; template using vvc = vc>; template using vvvc = vc>; template using pq = priority_queue>; template using pq_g = priority_queue, greater>; const ll INF = 2e18; const vc dx = {1, 1, 1, 0, 0, -1, -1, -1}; const vc dy = {1, 0, -1, 1, -1, 1, 0, -1}; //ライブラリ貼るところ //ここまで void solve(){ 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(n + 1, vector>(k + 1, vector(d + 1, -INF))); dp[0][0][0] = 0; for(int i = 0; i < n; ++i){ for(ll j = 0; j <= k; ++j){ for(int l = 0; l < d; ++l){ if(dp[i][j][l] != -INF){ if(j + c[i] <= k) chmax(dp[i + 1][j + c[i]][l + 1], dp[i][j][l] + a[i]); else chmax(dp[i + 1][k][l + 1], dp[i][j][l] + a[i]); } chmax(dp[i + 1][j][l], dp[i][j][l]); } chmax(dp[i + 1][j][d], dp[i][j][d]); } } if(dp[n][k][d] == -INF) cout << "No" << "\n"; else cout << dp[n][k][d] << "\n"; } int main(){ cin.tie( nullptr ); ios::sync_with_stdio( false ); cout << setprecision( 15 ) << fixed; int t = 1; for(int i = 0; i < t; ++i) solve(); }