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

递归超时 然后用动归16ms

Posted by Ink213 at 2013-03-01 14:24:23 on Problem 1163
#include<cstdio>
using namespace std;
int s[240][240];
int n;
int max(int a,int b)
{
    return a>b?a:b;
}
int main()
{
    int a;
    int i,j;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0; i<n; i++)
            for(j=110-i; j<=110+i; j+=2)
            {
                scanf("%d",&a);
                s[i][j]=a;
            }
        for(i=n-1; i>0; i--)
            for(j=110-i; j<110+i; j+=2)
                s[i-1][j+1]+=max(s[i][j],s[i][j+2]);
        printf("%d\n",s[0][110]);
    }
    return 0;
}

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