ZGS_WZY @ 2018-05-31 19:24:09
using namespace std;
long long read(){
char c=getchar();
long long num=0;long long f=1;
while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){num=num*10+(c-'0');c=getchar();}
return num*f;
}
void qwq(long long x){
if(x>9)qwq(x/10);
putchar(x%10+'0');
}
void write(long long x){
if(x<0){x=-x;putchar('-');}
qwq(x);putchar('\n');
}
struct wzy{
long long ai,bi,ci;
}container[60];
long long dp[100010];
bool cmp(wzy a,wzy b){
return (a.bi*a.ci)<(b.bi*b.ci);
}
int main(){
long long T=read();long long N=read();
for(long long i=1;i<=N;i++)container[i].ai=read();
for(long long i=1;i<=N;i++)container[i].bi=read();
for(long long i=1;i<=N;i++)container[i].ci=read();
sort(container+1,container+N+1,cmp);
for(long long i=1;i<=N;i++){
for(long long j=T;j>=container[i].ci;j--){
dp[j]=max(dp[j],dp[j-container[i].ci]+(container[i].ai-j*container[i].bi));
}
}
long long ans=0;
for(long long i=1;i<=T;i++)ans=max(ans,dp[i]);
write(ans);
return 0;
}
by ZGS_WZY @ 2018-05-31 19:27:03
查出来了,是cmp写错了