1018 -- 最长平台

最长平台

Time Limit:1000MS  Memory Limit:65536K
Total Submit:225 Accepted:92

Description

已知一个已经从小到大排列好的数组,说这个数组中的一个平台
(Plateau),就是连续的一串值相同的元素,并且这一串元素不能再延
伸。例如,在 1,2,2,3,3,3,4,5,5,6 中 1,2.2,3.3.3,4,
5.5,6 都是平台。试编写一个程序,接收一个数组,把这个数组中最长的
平台找出来。在上面的例子中 3.3.3 是该数组中最长的平台。(注:为了
方便,测试用例的数组最大长度都不超过 50,数组中的元素全部为整数范
围为[-2^31,2^31-1])。

Input

多组测试数据,处理到文件结尾。每组数据首先由一个数组的长度 L,随后
跟随 L 个该数组数据组成。

Output

对于每个测试用例输出它的最长平台

Sample Input

10
1 2 2 3 3 3 4 5 5 6
11
1 1 1 1 1 1 2 2 2 2 2
5
1 2 3 4 5

Sample Output

3
6
1

Source

ahstu@ICPC02

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    namespace AK1018 {
        class Program {
            static void Main(string[] args) {
                string sb;
                while ((sb = Console.ReadLine()) != null) {
                    int n = int.Parse(sb);
                    int[] a = new int[10005];
                    string[] s = Console.ReadLine().Split();
                    for (int i = 0; i < n; i++)
                        a[i] = int.Parse(s[i]);
                    int count = 1;
                    for (int i = 1; i < n; i++) {
                        if (a[i] == a[i - count])
                            count++;
                    }
                    Console.WriteLine(count);
                }
            }
        }
    }


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值