Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class LongestInArr
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int count = 0;
- int bestcount = 0;
- string container = "";
- List<string> strList = new List<string>();
- for (int i = 0; i < n; i++)
- {
- strList.Add(Console.ReadLine());
- }
- for (int i = 0; i < strList.Count; i++)
- {
- for (int j = 0; j < strList.Count; j++)
- {
- if (j + 1 <= strList.Count)
- {
- if (strList[i] == strList[j])
- {
- count++;
- }
- else
- {
- if (count > bestcount)
- {
- bestcount = count;
- count = 0;
- if (container != strList[i])
- {
- container = "";
- container += strList[i];
- }
- }
- else
- {
- count = 0;
- }
- }
- }
- }
- }
- Console.WriteLine(bestcount);
- for (int i = 0; i < bestcount; i++)
- {
- Console.WriteLine(container);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement