• <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 - 195,  comments - 30,  trackbacks - 0

            Your teacher has given you some problems to solve. You must first solve problem 0. After solving each problem i, you must either move on to problem i+1 or skip ahead to problem i+2. You are not allowed to skip more than one problem. For example, {0, 2, 3, 5} is a valid order, but {0, 2, 4, 7} is not because the skip from 4 to 7 is too long.

            You are given N integers, where the ith integer indicates how much you like problem i. The teacher will let you stop solving problems once the range of pleasantness you've encountered reaches a certain threshold. Specifically, you may stop once the difference between the maximum and minimum pleasantness of the problems you've solved is greater than or equal to a integer K. If this never happens, you must solve all the problems.

            Input

            The input contains several test cases. For each case it contains two positive integer N, K (1<=N<=50, 1<=K<=1000), then N integers follow in the next line, the ith integer ( >=1 and <= 1000 ) indicates how much you like problem i.

            Output

            For each test case, output the minimum number of problems you must solve to satisfy the teacher's requirements.

            Sample Input

            3 2
            1 2 3
            5 4
            1 2 3 4 5

            Sample Output

            2
            3
            很笨但是很實用!
            #include<stdio.h>
            int a[51];
            int main()
            {
            int n,k;
            while(scanf("%d%d",&n,&k)!=EOF)
            {
            int i,j;
            for(i=0;i<n;i++)
            scanf("%d",a+i);
            int min=0xfffffff;
            int flag=0;
            for(i=1;i<n;i++)
            for(j=0;j<i;j++)
            {
            if(a[i]-a[j]>=k||a[j]-a[i]>=k)
            {
            flag=1;
            int step;
            if(j==0)
            {
            step=(i+1)/2+1;
            if(min>step)
            min=step;
            }
            else
            {
            step=(i-j+1)/2+(j+1)/2+1;
            if(min>step)
            min=step;
            }
            }
            }
            if(flag)
            printf("%d\n",min);
            else
            printf("%d\n",n);
            }
            return 0;
            }
            posted on 2009-06-28 22:26 luis 閱讀(250) 評論(0)  編輯 收藏 引用 所屬分類: 給我啟發(fā)題
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久久精品免费国产四虎| 久久久久婷婷| 国产精品成人99久久久久| 精品一久久香蕉国产线看播放| 欧美色综合久久久久久| AV无码久久久久不卡网站下载| 久久精品国产一区二区三区不卡| 狠狠色丁香婷婷久久综合五月| 国产精品无码久久久久久| 无码任你躁久久久久久老妇| 国产Av激情久久无码天堂| 少妇无套内谢久久久久| 超级碰久久免费公开视频| 久久国产高潮流白浆免费观看| 亚洲午夜无码久久久久小说| 免费国产99久久久香蕉| 久久精品国产亚洲AV无码娇色| 久久久久人妻一区精品| 国产99久久九九精品无码| 国产99精品久久| 欧美丰满熟妇BBB久久久| 亚洲精品国产综合久久一线| 久久精品国产亚洲5555| 成人国内精品久久久久影院| 久久精品国产2020| 久久久久久国产精品无码下载| 看全色黄大色大片免费久久久| 99久久国产热无码精品免费久久久久| 久久精品无码午夜福利理论片| 99久久香蕉国产线看观香| 久久人人青草97香蕉| 色播久久人人爽人人爽人人片AV| 伊人情人综合成人久久网小说| 久久综合久久伊人| 亚洲国产成人久久精品99 | 精品久久久久成人码免费动漫 | 狠狠色丁香婷婷久久综合| 亚洲欧美国产精品专区久久| 亚洲欧洲精品成人久久奇米网| 久久夜色精品国产| 2021最新久久久视精品爱|