45462023-03-29 14:12:37TortelliniJrLeghosszabb béke (75 pont)csharpTime limit exceeded 6/75282ms28752 KiB
using System;
using System.Linq;
namespace Vásárlás
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool[] hab = new bool[inp[0] + 1];
            int[] yes = new int[2];
            for (int i = 0; i < inp[1]; i++)
            {
                yes = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int u = yes[0]; u <= yes[1]; u++)
                {
                    hab[u] = true;
                }
            }
            int longest = 0;
            int jel = 0;
            int jelkezd = 1;
            int[] longests = new int[2];
            for (int i = 1; i < inp[0] + 1; i++)
            {
                if (hab[i])
                {
                    if (jel > longest)
                    {
                        longest = jel;
                        longests[0] = jelkezd;
                        longests[1] = i + 1;
                    }
                    jel = 0;
                    jelkezd = i + 1;
                }
                else
                {
                    jel++;
                }
            }
            Console.WriteLine(longest + " " + longests[0]);
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base6/75
1Accepted0/032ms22004 KiB
2Time limit exceeded0/0273ms8560 KiB
3Wrong answer0/330ms22644 KiB
4Accepted3/330ms23328 KiB
5Wrong answer0/330ms23244 KiB
6Accepted3/330ms23716 KiB
7Wrong answer0/330ms23844 KiB
8Wrong answer0/430ms24132 KiB
9Wrong answer0/430ms24532 KiB
10Wrong answer0/432ms24540 KiB
11Wrong answer0/457ms27748 KiB
12Wrong answer0/486ms28392 KiB
13Wrong answer0/467ms27360 KiB
14Wrong answer0/471ms28068 KiB
15Wrong answer0/486ms28752 KiB
16Time limit exceeded0/4236ms9176 KiB
17Time limit exceeded0/4238ms8820 KiB
18Time limit exceeded0/4270ms8676 KiB
19Time limit exceeded0/4282ms9772 KiB
20Time limit exceeded0/4250ms7820 KiB
21Time limit exceeded0/4282ms7988 KiB
22Time limit exceeded0/4241ms8168 KiB