46942023-03-31 09:21:53csicsilla70Leghosszabb béke (75 pont)csharpWrong answer 6/75172ms32832 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace leghosszabb_béke
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] sor = Console.ReadLine().Split();
            int napok = int.Parse(sor[0]);
            int[] x = new int[napok];
            int n = int.Parse(sor[1]);           
            for (int i = 0; i < n; i++)
            {
                sor = Console.ReadLine().Split();
                x[int.Parse(sor[0])]++;
                x[int.Parse(sor[1])]--;
            }
            int szamlalo = 0;
            int k = 0, v = 0, mh = 0, mi = 0;
            for (int i = 0; i < napok; i++)
            {
                szamlalo += x[i];
                if (szamlalo > 0) k = i + 1;
                else v = i;
                if(v - k > mh)
                { mh = v - k; mi = k; }
            }
            if (mh == 0) Console.WriteLine(-1);
            else Console.WriteLine(mh + " " + (mi+1));
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base6/75
1Accepted0/028ms20640 KiB
2Wrong answer0/0172ms29464 KiB
3Runtime error0/330ms20836 KiB
4Accepted3/328ms21748 KiB
5Wrong answer0/328ms22100 KiB
6Accepted3/328ms22216 KiB
7Wrong answer0/328ms22596 KiB
8Wrong answer0/428ms22740 KiB
9Wrong answer0/428ms23292 KiB
10Wrong answer0/428ms23172 KiB
11Wrong answer0/435ms25128 KiB
12Wrong answer0/439ms25952 KiB
13Wrong answer0/435ms25296 KiB
14Wrong answer0/437ms25424 KiB
15Wrong answer0/439ms26120 KiB
16Runtime error0/429ms23488 KiB
17Runtime error0/429ms24112 KiB
18Runtime error0/429ms24424 KiB
19Wrong answer0/4167ms32832 KiB
20Runtime error0/428ms24256 KiB
21Runtime error0/429ms24972 KiB
22Runtime error0/429ms25296 KiB