#include <bits/stdc++.h>
using namespace std;
int n, s, d, a[1010], t[1010], f[1010][110][2];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// freopen("VD1.INP", "r", stdin);
// freopen("VD1.OUT", "w", stdout);
cin >> n >> s >> d;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
cin >> t[i];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= s; j++)
{
f[i][j][0] = max(f[i - 1][j][0], f[i - 1][j][1]);
for (int k = max(0, i - d); k < i; k++)
if (j >= t[i])
f[i][j][1] = max(f[i][j][1], f[k][j - t[i]][1] + a[i]);
}
cout << max(f[n][s][0], f[n][s][1]);
return 0;
}
///******************20210080******************///
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBuLCBzLCBkLCBhWzEwMTBdLCB0WzEwMTBdLCBmWzEwMTBdWzExMF1bMl07CgppbnQgbWFpbigpCnsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogICAgY2luLnRpZShOVUxMKTsKICAgIGNvdXQudGllKE5VTEwpOwoKICAgIC8vIGZyZW9wZW4oIlZEMS5JTlAiLCAiciIsIHN0ZGluKTsKICAgIC8vIGZyZW9wZW4oIlZEMS5PVVQiLCAidyIsIHN0ZG91dCk7CgogICAgY2luID4+IG4gPj4gcyA+PiBkOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKQogICAgICAgIGNpbiA+PiBhW2ldOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKQogICAgICAgIGNpbiA+PiB0W2ldOwoKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykKICAgICAgICBmb3IgKGludCBqID0gMTsgaiA8PSBzOyBqKyspCiAgICAgICAgewogICAgICAgICAgICBmW2ldW2pdWzBdID0gbWF4KGZbaSAtIDFdW2pdWzBdLCBmW2kgLSAxXVtqXVsxXSk7CiAgICAgICAgICAgIGZvciAoaW50IGsgPSBtYXgoMCwgaSAtIGQpOyBrIDwgaTsgaysrKQogICAgICAgICAgICAgICAgaWYgKGogPj0gdFtpXSkKICAgICAgICAgICAgICAgICAgICBmW2ldW2pdWzFdID0gbWF4KGZbaV1bal1bMV0sIGZba11baiAtIHRbaV1dWzFdICsgYVtpXSk7CiAgICAgICAgfQoKICAgIGNvdXQgPDwgbWF4KGZbbl1bc11bMF0sIGZbbl1bc11bMV0pOwoKICAgIHJldHVybiAwOwp9CgovLy8qKioqKioqKioqKioqKioqKioyMDIxMDA4MCoqKioqKioqKioqKioqKioqKi8vLw==