#include #include using namespace std; using namespace atcoder; using mint = modint998244353; //using mint = modint1000000007; using ll = long long; ll INF = 2e18; template using vc = vector; template using vv = vc>; using vi = vc; using vvi = vv; using vl = vc; using vvl = vv; using vs = vc; using vvs = vv; using vb = vc; using vvb = vv; using vmint = vc; using vvmint = vv; #define rep(i,n) for(ll i=0; i<(n); i++) #define drep(i,n) for(ll i=(n)-1; i>=0; i--) #define rrep(i,n) for(ll i=1; i<=(n); i++) #define nfor(i,a,b) for(ll i=a;i=(b); i--) templateistream& operator>>(istream& i, vc& v) {rep(j,(ll) size(v))i >> v[j]; return i; } #define nall(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define chmax(x,y) x = max(x,y) #define chmin(x,y) x = min(x,y) #define YES cout<<"Yes"<> N >> D >> K; vl A(N), C(N); rep(i,N) cin >> A[i]; rep(i,N) cin >> C[i]; vvl dp(D+1,vl(K+1,-INF)); dp[0][0] = 0; rep(i,N) { vvl nextdp(D+1,vl(K+1,-INF)); rep(j,D+1) { rep(k,K+1) { if (dp[j][k] == -INF) continue; else { chmax(nextdp[j][k],dp[j][k]); if (j == D) continue; if (C[i]+k>=K) { chmax(nextdp[j+1][K],dp[j][k]+A[i]); } else { chmax(nextdp[j+1][k+C[i]],dp[j][k]+A[i]); } } } } dp = nextdp; } if (dp[D][K] == -INF) NO; else cout << dp[D][K] << endl; }