fid=fopen('data.txt','r');
a=fscanf(fid, '%d');
V=zeros(366,100);
v=zeros(366,100);
ucelova=zeros(1,26);
V(366,:)=inf;
V(366,1)=0;



for i=365:-1:1
     for x=0:99
         ucelova(:)=inf;
         for u=0:25
             fo(u+1)=100*(x+a(i)-u)+2000*sign(u);
             f(u+1)=x+a(i)-u;
             if f(u+1)<=99 && f(u+1)>=0
                ucelova(u+1)=fo(u+1)+V(i+1,f(u+1)+1);
            end
         end
         
         V(i,x+1)=min(ucelova);
         
     end
end
 
V(1,1)
