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 |
63 MS-G++#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator