poj 3176 Cow Bowling

#include <iostream>
#include <algorithm> 
using namespace std;

const int MAX = 400;
short dp[MAX][MAX]; 

int main()
{
    int n, i, j;
    while (cin >> n){
          for (i = 1; i <= n; i++){
              for (j = 1; j <= i; j++){
                  cin >> dp[i][j]; 
              } 
          } 
          
          for(i = n-1; i >= 1; i--){
	         for(j = 1; j <= i; j++)
		         dp[i][j] += max(dp[i+1][j],dp[i+1][j+1]);
          }
          cout << dp[1][1] << endl; 
    } 
    
    system("pause"); 
} 

你可能感兴趣的:(Algorithm,System,include)