package non2;
public class non {
int s,t,h;
double th=new double[101];
int x=new int[101];
int p=new int[101];
int ox=new int[101];
int op=new int[101];
int cost;
double u=new double[101][21][201];
double w=new double[101][21][201];
double up=new double[101][21][201];
int v=new int[101][21][201];
int rev=new int[101][21][201];
int gotox=new int[101][21][201];
int gotop=new int[101][21][201];
int x1,p1,x2,p2,xs,ps,r1,v1;
int maxv;
void makedata(){
for(s=1;s<101;s++){
for(x1=-10;x1<11;x1++){
for(p1=-100;p1<101;p1++){
ps=p[s]+p1;
xs=x[s]+x1;
h=0;
if(xs>0)h=h+1;
if(ps>0)h=h+1;
u[s][x1+10][p1+100]=0;
if(h==2)u[s][x1+10][p1+100]=th[s]*Math.log(xs+1)-ps;
}
}
}
for(s=1;s<100;s++){
for(x1=-10;x1<11;x1++){
for(p1=-100;p1<101;p1++){
ps=p[s]+p1;
xs=x[s]+x1;
w[s][x1+10][p1+100]=-999;
h=0;
if(xs>0)h=h+1;
if(ps>0)h=h+1;
if(h==2)w[s][x1+10][p1+100]=th[s+1]*Math.log(xs+1)-ps;
}
}
}
for(s=1;s<101;s++){
for(x1=-10;x1<11;x1++){
for(p1=-100;p1<101;p1++){
xs=x[s]+x1;
ps=p[s]+p1;
rev[s][x1+10][p1+100]=-999;
h=0;
if(xs>0)h=h+1;
if(ps>0)h=h+1;
if(u[s][x1+10][p1+100]<0)h=0;
if(h==2)rev[s][x1+10][p1+100]=ps-cost*xs;
h=0;
if(xs==0)h=h+1;
if(ps==0)h=h+1;
if(h==2)rev[s][x1+10][p1+100]=0;
}
}
}
s=1;
for(x1=-10;x1<11;x1++){
for(p1=-100;p1<101;p1++){
v[s][x1+10][p1+100]=rev[s][x1+10][p1+100];
}
}
double u1,w1;
int x3,x4;
for(s=2;s<101;s++){
for(x1=-10;x1<11;x1++){
for(p1=-100;p1<101;p1++){
r1=rev[s][x1+10][p1+100];
u1=u[s][x1+10][p1+100];
if(u1<0)r1=-999;
maxv=-9999;
x3=x[s]+x1;
xs=0;
ps=0;
for(x2=-10;x2<11;x2++){
for(p2=-100;p2<101;p2++){
w1=w[s-1][x2+10][p2+100];
x4=x[s-1]+x2;
v1=r1+v[s-1][x2+10][p2+100];
if(w1>u1)v1=-999;
if(x4>x3)v1=-999;
if(v1>maxv)xs=x2;
if(v1>maxv)ps=p2;
if(v1>maxv)maxv=v1;
}
}
v[s][x1+10][p1+100]=maxv;
gotop[s][x1+10][p1+100]=ps;
gotox[s][x1+10][p1+100]=xs;
}
}
}
s=100;
maxv=-999;
xs=0;
ps=0;
for(x1=-10;x1<11;x1++){
for(p1=-100;p1<101;p1++){
if(v[s][x1+10][p1+100]>maxv)ps=p1;
if(v[s][x1+10][p1+100]>maxv)xs=x1;
if(v[s][x1+10][p1+100]>maxv)maxv=v[s][x1+10][p1+100];
}
}
op[100]=ps;
ox[100]=xs;
System.out.println(maxv);
for(t=1;t<100;t++){
s=101-t;
p1=op[s];
x1=ox[s];
op[s-1]=gotop[s][x1+10][p1+100];
ox[s-1]=gotox[s][x1+10][p1+100];
}
for(s=1;s<101;s++){
p[s]=p[s]+op[s];
x[s]=x[s]+ox[s];
}
}
}