Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:我也一次AC。。呵呵(附代码)

Posted by NENU08022 at 2009-07-30 16:11:51 on Problem 1157
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;
> }
3 5
7 23 -5 -24 16
105 21 -4 10 23
-21 5 -4 -20 20
要是这组数据,正确答案应该是多少呢

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator