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 |
DP第2次AC#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator