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,贴代码飘过~~~#include <iostream> using namespace std; int map[351][351]; int dp[351][351]; int cmax(int a,int b) {return a > b ? a : b;} int main() { int n,i,j,k; while(scanf("%d",&n)!=EOF) { for(i = 0,k = 1;i < n;i ++,k++) for(j = 0;j < k;j++) scanf("%d",&map[i][j]); memset(dp,0,sizeof(dp)); for(i = n - 1;i >= 0;i--) for(j = 0;j <= i;j++) dp[i][j] = cmax(dp[i + 1][j],dp[i + 1][j + 1]) + map[i][j]; printf("%d\n",dp[0][0]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator