#include <bits/stdc++.h>
using namespace std;
#define max(a, b) ((a) < (b) ? b : a)
#pragma optimize("O3")
#pragma optimize("unroll-loops")
int n, m, tt;
const int maxn = 3e5 + 100;
int a[maxn], b[maxn];
long long p[maxn], ans[maxn];
vector<int> d;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n;
    cin >> m >> tt;
    d.reserve(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    for (int i = 0; i < n; i++)
        p[i + 1] = p[i] + a[i];
    for (int i = 0; i < n; i++)
        ans[i] = tt / a[i];
    long long bb;
    for (int i = 1; i < n; i++) {
        while (!d.empty() && a[d.back()] > a[i - 1])
            d.pop_back();
        d.push_back(i - 1);
        for (int ind = 0; ind < d.size() && ind <= 400; ind++) {
            int j = d[ind];
            bb = i - j + (tt - (p[i + 1] - p[j + 1])) / a[j];
            ans[i] = max(ans[i], bb);
        }
    }
    d.clear();
    for (int i = n - 2; i >= 0; i--) {
        while (!d.empty() && a[d.back()] > a[i + 1])
            d.pop_back();
        d.push_back(i + 1);
        for (int ind = 0; ind < d.size() && ind <= 400; ind++) {
            int j = d[ind];
            bb = j - i + (tt - (p[j] - p[i])) / a[j];
            ans[i] = max(ans[i], bb);
        }
    }
    long long rl = -1;
    for (int i = 0; i < m; i++)
        rl = max(rl, ans[b[i] - 1]);
    cout << rl << "\n";
    return 0;
}