Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

菜鸟级DP,贴代码

Posted by scissorsy at 2016-01-15 10:55:22 on Problem 3176
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator