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

DP第2次AC

Posted by shoutz at 2013-04-12 21:15:45 on Problem 1163
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    int ma[110][110];
    int dp[110][110];
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)
            for(int j=1;j<=i;j++)
            cin>>ma[i][j];
        for(int i=1;i<=n;i++)
            dp[n][i]=ma[n][i];
        for(int i=n-1;i>=1;i--)
            for(int j=1;j<=i;j++)
        {
            dp[i][j]=max(ma[i][j]+dp[i+1][j],ma[i][j]+dp[i+1][j+1]);
        }
        cout<<dp[1][1]<<'\n';
    }
    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