sutacm

手机发个博客真不容易啊,来一道简单的题吧poj1163

View Code
 1 #include<stdio.h>
 2 
 3 int main()
 4 {
 5     int n, i, j, a, dp[128] = { 0 };
 6     scanf("%d", &n);
 7     i = n;
 8     while (i--)
 9     {
10         for (j = i; j < n; j++)
11         {
12             scanf("%d", &a);
13             dp[j] = (dp[j] > dp[j + 1]) ? dp[j] + a : dp[j + 1] + a;
14         }
15     }
16     for (i = 1, j = 0; i <= n; i++)
17         if (dp[j] < dp[i])
18             j = i;
19     printf("%d\n", dp[j]);
20     return 0;
21 }

 

 

posted @ 2013-01-01 18:31  sut_ningwei  阅读(92)  评论(0编辑  收藏  举报