46892023-03-31 08:59:05TortelliniJrLeghosszabb béke (75 pont)csharpWrong answer 3/75199ms34184 KiB
using System;
using System.Linq;
namespace LeghosszabbBeke
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] napok = new int[inp[0]];
            int[] temp = new int[2];
            for (int i = 0; i < inp[1]; i++)
            {
                temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                napok[temp[0]]++;
                napok[temp[1]]--;
            }
            int counter = 0;
            int longestpeace = 0;
            int currentpeace = 0;
            int longestbegin = 0;
            for (int i = 0; i < inp[0]; i++)
            {
                if (napok[i] > 0)
                {
                    counter += napok[i];
                }
                if (counter == 0)
                {
                    currentpeace++;
                }
                else
                {
                    if (currentpeace > longestpeace)
                    {
                        longestpeace = currentpeace;
                        longestbegin = i - currentpeace;
                    }
                    currentpeace = 0;
                }
                if (napok[i] < 0)
                {
                    counter += napok[i];
                }
            }
            if (currentpeace > longestpeace)
            {
                longestpeace = currentpeace;
                longestbegin = inp[0] - 1 - currentpeace;
            }
            if (longestpeace == 0)
            {
                Console.WriteLine("-1");
            }
            else
            {
                Console.WriteLine(longestpeace + " " + longestbegin);
            }
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base3/75
1Accepted0/032ms21924 KiB
2Wrong answer0/0199ms30704 KiB
3Runtime error0/332ms22064 KiB
4Wrong answer0/329ms22784 KiB
5Wrong answer0/329ms22876 KiB
6Accepted3/329ms23320 KiB
7Wrong answer0/329ms23852 KiB
8Wrong answer0/429ms23828 KiB
9Wrong answer0/429ms23792 KiB
10Wrong answer0/432ms24684 KiB
11Wrong answer0/441ms27444 KiB
12Wrong answer0/446ms28720 KiB
13Wrong answer0/439ms27480 KiB
14Wrong answer0/443ms27928 KiB
15Wrong answer0/443ms29116 KiB
16Runtime error0/434ms24904 KiB
17Runtime error0/432ms25280 KiB
18Runtime error0/432ms25444 KiB
19Wrong answer0/4186ms34184 KiB
20Runtime error0/434ms25684 KiB
21Runtime error0/432ms26040 KiB
22Runtime error0/434ms25956 KiB