欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

SZU:A12 Jumping up and down

系統 1926 0

Judge Info

  • Memory Limit: 32768KB
  • Case Time Limit: 10000MS
  • Time Limit: 10000MS
  • Judger: Number Only Judger

Description

In the kingdom of frog, the most popular sport is jumping up and down. Frog likes to jump up(go higher) or jump down(go lower) but jump at the same height(not go higher,and not go lower). The frog king wants to have a sport path for jumping. The Sport path is made by same size blocks which may have different height,when the frog on the path, he can only jumps from one block to the next adjacent block. For frog, perfect path for jumping are those same-height-jumps can be avoided. The Sport path can be represented by an integer sequence which denotes the height of blocks.The length of the sport path is the numbers of integer in the sequence.

Task

Now, it is your turn. You will have a integer sequence represent a sport path, please output the longest perfect path we can find in the given sport path without cutting off.

Input

The first line of input contains?, the number of test cases. There are two lines for each test case. The first line contains an integer number?denoting how many blocks in the sport path. The second line contains? N ?integer numbers (the height of blocks in the range? [ ? 100,100] ).

Output

For each test case, print a line contains the solution.

Sample Input

    2

8

1 1 3 5 5 7 9 8

5

1 2 3 4 5


  

Sample Output

    4

5
    


解題思路:剛開始讀不懂題意,以為是消除相同數和其本身,經過朋友說下才明白,原來是找最長的子串,但是遇到重復數字就開始新的字符串序列。
剛開始用了兩個數組,之后用一個數組,而ACMser都不用開數組。

      
         1
      
       #include <stdio.h>


      
         2
      
       #include <
      
        string
      
      .h>


      
         3
      
      
        int
      
       A[
      
        103
      
      
        ];


      
      
         4
      
      
         5
      
      
        int
      
      
         main() {


      
      
         6
      
      
        int
      
      
         t,i,n,pre,max,count,min;


      
      
         7
      
           scanf(
      
        "
      
      
        %d
      
      
        "
      
      ,&
      
        t);


      
      
         8
      
      
        while
      
       (t--
      
        ) {


      
      
         9
      
               max = 
      
        1
      
      
        ;


      
      
        10
      
               scanf(
      
        "
      
      
        %d
      
      
        "
      
      ,&
      
        n);


      
      
        11
      
      
        for
      
       (i=
      
        0
      
      ;i<n;i++
      
        ) {


      
      
        12
      
                   scanf(
      
        "
      
      
        %d
      
      
        "
      
      , &
      
        A[i]);


      
      
        13
      
      
                }


      
      
        14
      
               pre = 
      
        0
      
      
        ;


      
      
        15
      
               count =
      
        1
      
      
        ;


      
      
        16
      
      
        for
      
       (i=
      
        1
      
      ;i<n;++
      
        i) {


      
      
        17
      
      
        18
      
      
        if
      
      (A[i]==
      
        A[pre]){


      
      
        19
      
      
        if
      
      (count>
      
        max)


      
      
        20
      
                           max =
      
         count;


      
      
        21
      
                       count =
      
        1
      
      
        ;


      
      
        22
      
      
        continue
      
      
        ;


      
      
        23
      
      
                    }


      
      
        24
      
                   count++
      
        ;


      
      
        25
      
                   pre=
      
        i;


      
      
        26
      
      
                }


      
      
        27
      
               min =
      
         count;


      
      
        28
      
      
        if
      
       (min >
      
         max)


      
      
        29
      
                   max =
      
         min;


      
      
        30
      
               printf(
      
        "
      
      
        %d\n
      
      
        "
      
      
        ,max);


      
      
        31
      
      
            }


      
      
        32
      
       }
    

?

朋友的做法(不開數組):

      
         1
      
       #include <stdio.h>


      
         2
      
      
        int
      
       process(
      
        int
      
      
         n);


      
      
         3
      
      
        int
      
      
         main()


      
      
         4
      
      
        {


      
      
         5
      
      
        int
      
      
         testcase;


      
      
         6
      
           scanf(
      
        "
      
      
        %d
      
      
        "
      
      , &
      
        testcase);


      
      
         7
      
      
        while
      
       (testcase--
      
        ) {


      
      
         8
      
      
        int
      
      
         n;


      
      
         9
      
               scanf(
      
        "
      
      
        %d
      
      
        "
      
      , &
      
        n);


      
      
        10
      
               printf(
      
        "
      
      
        %d\n
      
      
        "
      
      
        , process(n));


      
      
        11
      
      
            }


      
      
        12
      
      
        }


      
      
        13
      
      
        int
      
       process(
      
        int
      
      
         n)


      
      
        14
      
      
        {


      
      
        15
      
      
        int
      
      
         i, pre, cur;;


      
      
        16
      
           scanf(
      
        "
      
      
        %d
      
      
        "
      
      , &
      
        pre);


      
      
        17
      
      
        int
      
       cnt = 
      
        1
      
      , cur_max = 
      
        1
      
      
        ;


      
      
        18
      
      
        for
      
       (i = 
      
        1
      
      ; i != n; i++
      
        ) {


      
      
        19
      
               scanf(
      
        "
      
      
        %d
      
      
        "
      
      , &
      
        cur);


      
      
        20
      
      
        if
      
       (cur ==
      
         pre) {


      
      
        21
      
      
        if
      
       (cur_max <
      
         cnt)


      
      
        22
      
                       cur_max =
      
         cnt;


      
      
        23
      
                   cnt = 
      
        1
      
      
        ;


      
      
        24
      
      
                }


      
      
        25
      
      
        else
      
      
         {


      
      
        26
      
                   cnt++
      
        ;


      
      
        27
      
      
                }


      
      
        28
      
               pre =
      
         cur;


      
      
        29
      
      
            }


      
      
        30
      
      
        if
      
       (cur_max <
      
         cnt)


      
      
        31
      
               cur_max =
      
         cnt;


      
      
        32
      
      
        return
      
      
         cur_max;


      
      
        33
      
       }
    

?

    
      ?
    
  

SZU:A12 Jumping up and down


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 成人观看网站a | WWW国产亚洲精品久久久 | 亚洲天堂网在线观看 | 陈宝莲a毛片在线播放 | 欧美激情在线精品一区二区 | 久久久久久久久久久久久久久久久久久 | 一级做性色a爰片久久毛片 亚洲午夜精品久久久久久app | 毛片在线视频观看 | 黄色国产视频 | 亚洲十欧美十日韩十国产 | 久久久久久久久淑女av国产精品 | 久久国产免费看 | 日韩有码一区二区三区 | 亚洲人成在线播放 | 国产欧美一区二区三区久久人妖 | 99热综合在线 | 国产亚洲综合一区二区在线 | 青娱乐综合网 | 亚洲欧美激情视频 | 性做久久久| 日韩有码在线播放 | 欧美日韩国产在线 | 日本精品不卡 | 激情丁香婷婷 | 色婷婷综合缴情综六月 | 九九爱这里只有精品 | 黄色片av | 国产欧美日韩不卡一区二区三区 | 丁香久久 | 成a人v在线观看视频 | 日韩午夜三级 | 精品国精品国产自在久国产应用 | 亚洲毛片网站 | 国产精品亚洲视频 | 国产免费福利视频一区二区 | 免费一级毛片不卡在线播放 | 亚洲精品在线第一页 | 免费看h网站 | 狠狠色狠狠色综合久久第一次 | 亚洲福利一区福利三区 | 免费人成在线播放 |