45962023-03-30 10:39:29TortelliniJrKert (75 pont)csharpRuntime error 68/75456ms74680 KiB
using System;
using System.Linq;
using System.Collections.Generic;
namespace Kert
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            List<int> temp = new List<int>();
            int dom = 0;
            int azonosmax = 0;
            for (int u = 0; u < inp[0]; u++)
            {
                temp = Console.ReadLine().Split().Select(int.Parse).ToList();
                int most = temp.GroupBy(i => i).OrderByDescending(grp => grp.Count()).First().Count();
                if (most > inp[1] / 2)
                {
                    dom++;
                }
                int longestSeriesCount = temp.Skip(1)
                             .Aggregate(new { Value = temp[0], Count = 1, Longest = new { Value = temp[0], Count = 1 } },
                                        (acc, x) => x == acc.Value ? new { Value = x, Count = acc.Count + 1, Longest = acc.Count + 1 > acc.Longest.Count ? new { Value = x, Count = acc.Count + 1 } : acc.Longest } :
                                                                   new { Value = x, Count = 1, Longest = acc.Longest })
                             .Longest.Count;
                if (longestSeriesCount > azonosmax)
                {
                    azonosmax = longestSeriesCount;
                }
            }
            Console.WriteLine(dom);
            Console.WriteLine(azonosmax);
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base68/75
1Accepted0/039ms22360 KiB
2Accepted0/0428ms68636 KiB
3Accepted4/441ms23200 KiB
4Accepted4/439ms23316 KiB
5Accepted4/439ms23508 KiB
6Accepted4/439ms23816 KiB
7Accepted4/441ms24224 KiB
8Accepted4/441ms24784 KiB
9Accepted4/441ms24956 KiB
10Accepted4/452ms28392 KiB
11Accepted6/646ms25660 KiB
12Accepted6/661ms32088 KiB
13Accepted6/6100ms50976 KiB
14Accepted6/6435ms71088 KiB
15Accepted6/6389ms74584 KiB
16Accepted6/6456ms70600 KiB
17Runtime error0/7280ms74680 KiB