1018, hp1018
Longest Platform
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 225 Accepted: 92
Description
It is known that an array has been arranged from small to large, indicating a platform in this array.
(Plateau) is a continuous element with the same value, and this element cannot be extended.
Stretch. For example, in 2.2, 4,
5.5 and 6 are all platforms. Write a program to receive an array.
Find the platform. In the preceding example, 3.3.3 is the longest platform in the array. (Note:
Convenience. the maximum length of the array in the test case cannot exceed 50, and all elements in the array are integer
Enclosed in [-2 ^ 31,2 ^ 31-1]).
Input
Multiple groups of test data are processed to the end of the file. Each group of data is first composed of an array length of L, followed
It is composed of L data in the array.
Output
Maximum platform output for each test case
Sample Input
101 2 2 3 3 3 4 5 5 6111 1 1 1 1 1 2 2 2 2 251 2 3 4 5
Sample Output
361
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); } } } }
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger. Welcome to share your nice codes!