46902023-03-31 09:03:54TortelliniJrLeghosszabb béke (75 pont)csharpWrong answer 0/75188ms33812 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 + 1));
            }
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Wrong answer0/032ms21688 KiB
2Wrong answer0/0188ms31084 KiB
3Runtime error0/332ms21724 KiB
4Wrong answer0/330ms22320 KiB
5Wrong answer0/330ms22628 KiB
6Wrong answer0/330ms22808 KiB
7Wrong answer0/330ms23004 KiB
8Wrong answer0/430ms23104 KiB
9Wrong answer0/430ms23820 KiB
10Wrong answer0/432ms24280 KiB
11Wrong answer0/441ms27548 KiB
12Wrong answer0/443ms28220 KiB
13Wrong answer0/439ms26844 KiB
14Wrong answer0/441ms27584 KiB
15Wrong answer0/445ms28492 KiB
16Runtime error0/432ms24384 KiB
17Runtime error0/432ms24780 KiB
18Runtime error0/432ms24804 KiB
19Wrong answer0/4173ms33812 KiB
20Runtime error0/434ms25576 KiB
21Runtime error0/432ms25580 KiB
22Runtime error0/432ms25612 KiB