• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            心如止水
            Je n'ai pas le temps
            posts - 400,comments - 130,trackbacks - 0
            題解請參考:http://hi.baidu.com/knowledgetime/blog/item/49355560beadbf6e0c33fabc.html
            以下是我的代碼:
            /*
             * Author:  lee1r
             * Created Time:  2011/8/4 7:54:43
             * File Name: uva10891.cpp
             
            */
            #include
            <iostream>
            #include
            <sstream>
            #include
            <fstream>
            #include
            <vector>
            #include
            <list>
            #include
            <deque>
            #include
            <queue>
            #include
            <stack>
            #include
            <map>
            #include
            <set>
            #include
            <bitset>
            #include
            <algorithm>
            #include
            <cstdio>
            #include
            <cstdlib>
            #include
            <cstring>
            #include
            <cctype>
            #include
            <cmath>
            #include
            <ctime>
            #define L(x) ((x)<<1)
            #define R(x) (((x)<<1)+1)
            #define Half(x) ((x)>>1)
            #define lowbit(x) ((x)&(-(x)))
            using namespace std;
            const int kInf(0x7f7f7f7f);
            const double kEps(1e-11);
            typedef 
            long long int64;
            typedef unsigned 
            long long uint64;

            const int kMaxn(107);

            int n,r[kMaxn],sum[kMaxn],d[kMaxn][kMaxn];

            int Sum(int i,int j)
            {
                
            return sum[j]-sum[i-1];
            }

            int dp(int i,int j)
            {
                
            if(d[i][j]!=-1)
                    
            return d[i][j];
                d[i][j]
            =Sum(i,j);
                
            for(int k=i;k<j;k++)
                    d[i][j]
            =max(d[i][j],Sum(i,j)-dp(k+1,j));
                
            for(int k=i+1;k<=j;k++)
                    d[i][j]
            =max(d[i][j],Sum(i,j)-dp(i,k-1));
                
            return d[i][j];
            }

            int main()
            {
                
            //freopen("data.in","r",stdin);
                
                
            while(scanf("%d",&n)==1 && n)
                {
                    sum[
            0]=0;
                    
            for(int i=1;i<=n;i++)
                    {
                        scanf(
            "%d",&r[i]);
                        sum[i]
            =sum[i-1]+r[i];
                    }
                    
                    memset(d,
            -1,sizeof(d));
                    
            for(int i=1;i<=n;i++)
                        d[i][i]
            =r[i];
                    printf(
            "%d\n",dp(1,n)-Sum(1,n)+dp(1,n));
                }
                
                
            return 0;
            }
            posted on 2011-08-04 08:19 lee1r 閱讀(608) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:動態規劃
            久久丫忘忧草产品| 99久久亚洲综合精品成人| 99久久精品费精品国产一区二区| 亚洲综合熟女久久久30p| 久久大香香蕉国产| 日产久久强奸免费的看| 久久久噜噜噜www成人网| 精品综合久久久久久97超人| 中文精品久久久久人妻| 国内精品伊人久久久久网站| 国产亚洲色婷婷久久99精品| 久久久久久免费视频| 狠狠久久综合| 久久人人爽人人爽人人av东京热| 久久九九免费高清视频| 99热热久久这里只有精品68| 亚洲а∨天堂久久精品| 久久这里只精品国产99热| 欧美牲交A欧牲交aⅴ久久| 精品一二三区久久aaa片| 大伊人青草狠狠久久| 亚洲国产精品嫩草影院久久| 丰满少妇高潮惨叫久久久| 亚洲人成无码www久久久| 久久精品国产秦先生| 国产亚洲精品久久久久秋霞| 国产真实乱对白精彩久久| 国产精品美女久久久m| 亚洲精品tv久久久久久久久| 性做久久久久久久| 手机看片久久高清国产日韩| 精品免费久久久久国产一区| 国产成人久久精品激情 | 国产91久久综合| 久久精品中文无码资源站| 久久精品国产2020| 久久人人爽人人爽人人片AV高清 | 久久精品国产亚洲AV蜜臀色欲 | 久久99国产精品久久久| 久久A级毛片免费观看| 久久综合给久久狠狠97色|