• <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>
            posts - 74,  comments - 33,  trackbacks - 0

            TimeLimit : 1 Second ? Memorylimit : 32 Megabyte ?

            Totalsubmit : 590 ? Accepted : 131

            Anti-terrorism is becoming more and more serious nowadays. The country now has n soldiers,and every solider has a score.

            We want to choose some soldiers to fulfill an urgent task. The soldiers chosen must be adjacent to each other in order to make sure that they can cooperate well. And all the soldiers chosen must have an average score greater than a.

            Now, please calculate how many ways can the chief of staff choose the soldiers.

            Input

            The first line consists of a single integer t, indicating number of test cases.

            For each test case, the first line gives n, the number of soldiers, and a, the minimum possible average score(n<=100000,a<=10000). The second line gives n integers, corresponding to the soldiers' scores in order. All the scores are no greater than 10000.

            Output

            An integer n, number of ways to choose the soldiers.

            Sample Input

            2
            5 3
            1 3 7 2 4
            1 1000
            9999

            Sample Output

            10
            1
            一個簡稱CS的題目其實找到規律的話就很簡單了,一個Mergersort就能AC;
            Mergersort代碼如下:
            void?Mergersort(INT?l,INT?r){
            ????INT?i,j,sign;
            ????
            if(l>=r)return?;
            ????INT?mid
            =(l+r)>>1;
            ????Mergersort(l,mid);
            ????Mergersort(mid
            +1,r);
            ????sign
            =l,i=l,j=mid+1;
            ????
            while(i<=mid&&j<=r){
            ????????
            if(score[j]>score[i]){
            ????????????all
            +=mid-i+1;
            ????????????now[sign
            ++]=score[j++];????
            ????????}

            ????????
            else?now[sign++]=score[i++];????????
            ????}

            ????
            while(i<=mid)now[sign++]=score[i++];
            ????
            while(j<=r)now[sign++]=score[j++];
            ????
            for(i=l;i<=r;i++)
            ????????score[i]
            =now[i];
            ????
            return?;
            }
            posted on 2009-02-21 20:13 KNIGHT 閱讀(163) 評論(0)  編輯 收藏 引用
            <2009年3月>
            22232425262728
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            欧美久久亚洲精品| 久久精品国产亚洲网站| 久久中文字幕人妻熟av女| 亚洲成色WWW久久网站| 久久精品成人免费网站| 国产成人精品久久亚洲高清不卡| 欧美综合天天夜夜久久| 日韩人妻无码一区二区三区久久 | 久久久WWW成人免费毛片| 怡红院日本一道日本久久 | 亚洲精品tv久久久久久久久| 99久久精品国产高清一区二区| 精品国产乱码久久久久软件| 国产午夜久久影院| 久久国产欧美日韩精品| 久久久久久久久久久精品尤物| 热re99久久精品国产99热| 精品999久久久久久中文字幕 | 久久久久久久国产免费看| 激情综合色综合久久综合| 99国内精品久久久久久久| 囯产极品美女高潮无套久久久| 日韩美女18网站久久精品| 亚洲国产精品无码久久久久久曰| 久久综合五月丁香久久激情| 欧美午夜精品久久久久久浪潮| 久久乐国产综合亚洲精品| 久久精品国产99国产精品导航| 国产精品久久久久天天影视| 无码人妻精品一区二区三区久久久| 国内精品久久久久影院优 | 综合久久国产九一剧情麻豆 | 久久99国产精品久久99小说| 狠狠人妻久久久久久综合蜜桃| 国产精品成人99久久久久 | 国产精自产拍久久久久久蜜| 国产亚洲精久久久久久无码AV| 久久香综合精品久久伊人| 久久精品这里热有精品| 麻豆一区二区99久久久久| 人人狠狠综合88综合久久|