1.9.12

Source: Internet
Author: User

12: Longest Platform
Total time limit:
1000ms
Memory Limit:
65536kB
Describe

Known as an array that has been ordered from small to large, a platform (Plateau) of this array is a contiguous string of identical values, and this string of elements can no longer be extended. For example, 1,2-2,3-3-3,4,5-5,6 is a platform in 1,2,2,3,3,3,4,5,5,6. Try to write a program that receives an array and looks up the longest platform on the array. In the example above, 3-3-3 is the longest platform.

Input
the first line has an integer n (n <= 1000), which is the number of elements in the array. The second line has n integers, and the integers are separated by a single space.
Output
The
length of the longest platform is output.
Sample input
101 2 2 3 3 3 4 5 5 6
Sample output
3
Source
d.gries. The science of Programming, Springer-verlag, 1981
1#include <cstdio>2#include <cstring>3 using namespacestd;4 ints[1010];5 intMain ()6 {7     intN,ma=0, MA1;8scanf"%d",&n);9      for(intI=0; i<n;i++)Tenscanf"%d",&s[i]); One      for(intI=0; i<n;i++) A       { -ma1=0; -           intj=i; the            while(s[j]==S[i]) -           { -J + +; -ma1++; +           } -           if(MA1&GT;MA) ma=ma1; +       } Aprintf"%d", MA); at      return 0; -}

1.9.12

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.