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 |
递归超时 然后用动归16ms#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator