文件目录

#include <bits/stdc++.h>
using namespace std;
multiset<int> ms;
int n, a[105] = {}, b[105] = {}, c[105] = {}, l[105] = {}, t;
int getsum(int time, int num)
{
    if (time <= 0)
        return -1;
    for (int f = a[num]; f > 0; f -= b[num])
        ms.insert(f);
    int sum = 0;
    for (auto i = ms.rbegin(); i != ms.rend() && time; time--, i++)
        sum += *i;
    return sum;
}
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        cin >> b[i];
    for (int i = 1; i < n; i++)
        cin >> c[i];
    for (int i = 2; i <= n; i++)
        l[i] = l[i - 1] + c[i - 1];
    cin >> t;
    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans = max(ans, getsum(t - l[i], i));
    cout << ans;
    return 0;
}