46932023-03-31 09:21:34TortelliniJrLeghosszabb béke (75 pont)csharpWrong answer 72/75190ms33464 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] + 1];
            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 = 1;
            int currentpeace = 0;
            int longestbegin = 0;
            for (int i = 1; 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
base72/75
1Accepted0/032ms21724 KiB
2Accepted0/0190ms30844 KiB
3Wrong answer0/330ms22608 KiB
4Accepted3/330ms23028 KiB
5Accepted3/330ms23288 KiB
6Accepted3/330ms23968 KiB
7Accepted3/330ms23804 KiB
8Accepted4/430ms24132 KiB
9Accepted4/430ms24260 KiB
10Accepted4/432ms24408 KiB
11Accepted4/441ms27048 KiB
12Accepted4/445ms27956 KiB
13Accepted4/439ms26632 KiB
14Accepted4/441ms27072 KiB
15Accepted4/445ms27984 KiB
16Accepted4/445ms28212 KiB
17Accepted4/446ms28580 KiB
18Accepted4/448ms29268 KiB
19Accepted4/4175ms33040 KiB
20Accepted4/4180ms33152 KiB
21Accepted4/4172ms33464 KiB
22Accepted4/4180ms33432 KiB