Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:我也一次AC。。呵呵(附代码)In Reply To:我也一次AC。。呵呵(附代码) Posted by:TangMing at 2009-07-23 13:32:58 > DP很好,,可是还是用了16ms,0ms怎么得到》? > 代码如下: > #include<iostream> > int map[110][110]; > int ans[110][110]; > int main() > { > int i,j,f,v; > scanf("%d%d",&f,&v); > memset(map,0,sizeof(map)); > for(i=1;i<=f;i++) > for(j=1;j<=v;j++) > scanf("%d",&map[i][j]); > ans[1][1]=map[1][1]; > for(i=2;i<=v;i++) > { > if(ans[1][i-1]>map[1][i])ans[1][i]=ans[1][i-1]; > else ans[1][i]=map[1][i]; > } > for(i=2;i<=f;i++) > { > ans[i][i]=ans[i-1][i-1]+map[i][i]; > for(j=i+1;j<=v;j++) > { > if(ans[i][j-1]>ans[i-1][j-1]+map[i][j])ans[i][j]=ans[i][j-1]; > else ans[i][j]=ans[i-1][j-1]+map[i][j]; > } > } > printf("%d\n",ans[f][v]); > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator