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

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            日韩精品久久久肉伦网站 | 久久久久人妻精品一区| 国产成年无码久久久免费| 色综合久久久久综合体桃花网| 亚洲伊人久久大香线蕉综合图片| 无遮挡粉嫩小泬久久久久久久| 久久一日本道色综合久久| 久久综合久久综合久久| 亚洲伊人久久综合影院| 日日躁夜夜躁狠狠久久AV| 久久久久亚洲AV无码专区网站 | 久久久久亚洲精品日久生情| AV无码久久久久不卡蜜桃| 一级做a爰片久久毛片人呢| 日日狠狠久久偷偷色综合免费| 久久99精品久久久久久久不卡| 久久99热这里只有精品国产| 精品熟女少妇av免费久久| 亚洲日韩欧美一区久久久久我 | 国产精久久一区二区三区| 欧美激情一区二区久久久| 国产精品成人精品久久久| 久久精品欧美日韩精品| 少妇熟女久久综合网色欲| 精品免费久久久久国产一区| 国产精品久久久久无码av| 久久久久国产精品嫩草影院| 久久无码AV中文出轨人妻| 99久久精品费精品国产| 国产精品久久久久无码av| 狠狠色婷婷综合天天久久丁香 | 国产精品美女久久久m| 久久无码中文字幕东京热| 久久久人妻精品无码一区| 青青草国产精品久久久久| 99久久无色码中文字幕| 99久久精品国产麻豆| 久久午夜伦鲁片免费无码| 精品久久人妻av中文字幕| 久久久久亚洲精品天堂| 69SEX久久精品国产麻豆|