# 第八届山东省acm省赛dp

#### Problem Description

LYD loves codeforces since there are many Russian contests. In an contest lasting for T minutes there are n problems, and for theith problem you can get aiditi points, where ai indicates the initial points, di indicates the points decreased per minute (count from the beginning of the contest), and ti stands for the passed minutes when you solved the problem (count from the begining of the contest).
Now you know LYD can solve the ith problem in ci minutes. He can't perform as a multi-core processor, so he can think of only one problem at a moment. Can you help him get as many points as he can?

#### Input

The first line contains two integers n,T(0≤n≤2000,0≤T≤5000).
The second line contains n integers a1,a2,..,an(0<ai≤6000).
The third line contains n integers d1,d2,..,dn(0<di≤50).
The forth line contains n integers c1,c2,..,cn(0<ci≤400).

#### Output

Output an integer in a single line, indicating the maximum points LYD can get.

#### Example Input

3 10
100 200 250
5 6 7
2 4 10


#### Example Output

254

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,t;

struct node
{
int t,d,c;
double f;

}ff[2005];
bool cmp(node a,node b)
{
return a.f<b.f;
}
int dp[5000];

int main()
{
while(cin>>n>>t)
{memset(dp,0,sizeof(dp));
for(int i=1;i<=n;++i)
{
scanf("%d",&ff[i].t);
}
for(int i=1;i<=n;++i)
{
scanf("%d",&ff[i].d);
}
for(int i=1;i<=n;++i)
{
scanf("%d",&ff[i].c);ff[i].f=ff[i].c*1.0/ff[i].d;
}
sort(ff+1,ff+n+1,cmp);
int maxn=0;
for(int i=1;i<=n;++i)
{
for(int v=t;v>=ff[i].c;--v)
{
dp[v]=max(dp[v],dp[v-ff[i].c]+ff[i].t-ff[i].d*v);
maxn=max(dp[v],maxn);
}
}
cout<<maxn<<endl;
}

return 0;
}