【DP】捡苹果

时间:2023-03-08 20:09:51
【DP】捡苹果
#include<stdio.h>

int max(int a,int b)
{
int c;
if(a>b)
c=a;
else
c=b; return c;
} int main()
{
FILE *fin,*fout;
int a[][],i,j; fin=fopen("in.txt","r");
fout=fopen("out.txt","w"); for(i=;i<=;i++)
for(j=;j<=;j++)
a[i][j]=; for(i=;i<=;i++)
for(j=;j<=i;j++)
fscanf(fin,"%d",&a[i][j]); for(;i>=;i--)
for(j=;j<=i;j++)
a[i][j]=max(a[i-][j],a[i-][j+]); fprintf(fout,"%d\n",a[][]); fclose(fin);
fclose(fout);
getchar();
getchar();
return ;
}