ACM PKU 3176 Cow Bowling http://acm.pku.edu.cn/JudgeOnline/problem?id=3176

他奶奶的,我也做水题(DP水题)了,有必要鄙视一下:

#include <iostream>
using namespace std;

int num [351][351];
int sign[351];
int Max = 0;
int N;

void solve ()
{
 int i, j;
  for(i = N-1; i > 0; i--) 
   for (j = 1; j <= i; j++)
   {
    if (sign[j] + num[i][j] > sign[j+1] + num[i][j] )
               sign[j] += num[i][j];
    else 
     sign[j] = sign[j+1] + num[i][j];
   }
}

int main ()
{
 int i, j;
    memset(num, 0, sizeof (num));
 memset(sign,0,sizeof(sign));
 cin >> N;
 for (i = 1; i <=N ; i++)
  for (j = 1;j <= i; j++)
   scanf("%d", &num[i][j]);
  for (i = 1; i <= N; i++)
             sign[i] = num[N][i];
  solve();
  cout << sign[1] << endl; 
 return 0;
}

posted on 2011-05-06 18:46  _Clarence  阅读(62)  评论(0编辑  收藏

导航

统计