• <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>

            為生存而奔跑

               :: 首頁 :: 聯系 :: 聚合  :: 管理
              271 Posts :: 0 Stories :: 58 Comments :: 0 Trackbacks

            留言簿(5)

            我參與的團隊

            搜索

            •  

            積分與排名

            • 積分 - 330192
            • 排名 - 74

            最新評論

            閱讀排行榜

            評論排行榜

            #include <iostream>
            #include 
            <algorithm>
            #include 
            <vector>
            #include 
            <string>
            using namespace std;
            const int maxsize=100;
            int n,S;
            bool visit[maxsize];
            int w[maxsize];
            int q[maxsize];
            int beibao()
            {
                
            int top=-1,begin=0,sum=0;
                
            int i;
                
            while(top!=-2)
                {
                    
            for(i=begin;i<n;i++)
                    {
                        
            if(!visit[i] && w[i]+sum<=S)
                        {
                            sum
            +=w[i];
                            q[
            ++top]=i;
                            begin
            =0;
                            visit[i]
            =1;
                            
            if(sum==S) return top;
                            
            break;
                        }
                    }
                    
            if(i==n)
                    {
                        visit[q[top]]
            =0;
                        sum
            -=w[q[top]];
                        begin
            =q[top]+1;
                        top
            --;
                    }
                }
            }
            int main()
            {
                cin
            >>n>>S;
                
            for(int i=0;i<n;i++)
                {
                    cin
            >>w[i];
                    visit[i]
            =0;
                }
                
            int t=beibao();
                
            if(t!=-1)
                {
                    
            for(int i=0;i<=t;i++)
                        cout
            <<w[q[i]]<<" ";
                    cout
            <<endl;
                }
                
            else cout<<-1<<endl;
            }

            posted on 2009-10-24 16:10 baby-fly 閱讀(1731) 評論(0)  編輯 收藏 引用 所屬分類: Algorithm
            人妻精品久久久久中文字幕69| 久久99国产一区二区三区| 亚洲国产另类久久久精品小说| 久久久久久久波多野结衣高潮| 久久久久久夜精品精品免费啦| 成人精品一区二区久久| 99久久国产宗和精品1上映| 久久综合九色综合97_久久久| 亚洲国产日韩欧美久久| 欧美一区二区精品久久| 狠狠精品久久久无码中文字幕| 国产精品成人99久久久久91gav| 中文国产成人精品久久亚洲精品AⅤ无码精品| 久久WWW免费人成一看片| 99久久99久久精品国产片| 久久人人爽人人爽人人片AV麻烦| 97超级碰碰碰碰久久久久| 色婷婷综合久久久久中文一区二区 | 精品国产日韩久久亚洲| 无码AV中文字幕久久专区| 久久亚洲AV永久无码精品| 久久精品嫩草影院| 精品熟女少妇a∨免费久久| 性做久久久久久免费观看 | 国产精品va久久久久久久| 精品人妻久久久久久888| 伊人色综合九久久天天蜜桃| 久久精品无码一区二区app| 国产精品免费久久久久影院| 91久久精品国产91性色也| 91亚洲国产成人久久精品| 18岁日韩内射颜射午夜久久成人 | 久久精品桃花综合| 亚洲中文字幕伊人久久无码| 亚洲国产成人精品久久久国产成人一区二区三区综 | 亚洲综合熟女久久久30p| 青青草国产97免久久费观看| 久久涩综合| 久久婷婷五月综合国产尤物app | 99久久超碰中文字幕伊人| 亚洲女久久久噜噜噜熟女|