#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******************///