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

63 MS-G++

Posted by lz1 at 2010-09-20 20:29:06 on Problem 3176
#include <stdio.h>
const int L=351;
int f[L][L],a[L][L];
int n,ans=-1;

int main(void){
    freopen ("3176.in","r",stdin);
    freopen ("3176.out","w",stdout);
    scanf ("%d",&n);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=i;j++)
            scanf ("%d",&a[i][j]);
    f[1][1]=a[1][1];
    for (int i=2;i<=n;i++)
        for (int j=1;j<=i;j++)
            if (f[i-1][j-1]>f[i-1][j])f[i][j]=f[i-1][j-1]+a[i][j];
            else f[i][j]=f[i-1][j]+a[i][j];
    for (int i=1;i<=n;i++)                 
        if (f[n][i]>ans)ans=f[n][i];
    printf ("%d",ans);
    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