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 <cstdio> #include <algorithm> using namespace std; const int MAX_N = 350; int main() { int dp[MAX_N][MAX_N]; int n; /*input*/ scanf("%d", &n); for(int i = 0;i<n;i++){ for(int j = 0;j<=i;j++) scanf("%d", &dp[i][j]); } /*input*/ /*dp*/ for(int i = n-2; i>= 0 ;i--) for(int j = i; j>=0 ; j--) dp[i][j] += max(dp[i+1][j], dp[i+1][j+1]); printf("%d", 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