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 |
20行 16ms#include <algorithm> #include <stdio.h> using namespace std; int dp[355][355]; int main(){ int n; scanf("%d", &n); for(int i = 0; i < n; i++) for(int j = 0; j < i + 1; j++){ scanf("%d", &dp[i][j]); if(i > 0){ if(j - 1 >= 0) dp[i][j] = dp[i][j] + max(dp[i-1][j], dp[i - 1][j - 1]); else dp[i][j] = dp[i][j] + dp[i - 1][j]; } } printf("%d\n", *(max_element(dp[n - 1], dp[n - 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