标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 33850 Accepted Submission(s):
20206
#include <string.h> #include <iostream> #include <algorithm> using namespace std; int main() { int i,j,n,t,a[105][105],dp[105][105]; cin>>t; while(t--) { memset(a,0,sizeof(a)); memset(dp,0,sizeof(dp)); cin>>n; for(i=0;i<n;i++) for(j=0;j<=i;j++) cin>>a[i][j]; for(j=0;j<n;j++) dp[n-1][j]=a[n-1][j]; for(i=n-2;i>=0;i--) for(j=0;j<=i;j++) dp[i][j]+=a[i][j]+max(dp[i+1][j],dp[i+1][j+1]); cout<<dp[0][0]<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/Ritchie/p/5425377.html