46952023-03-31 09:23:25csicsilla70Leghosszabb béke (75 pont)csharpWrong answer 6/75182ms33328 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/027ms20612 KiB
2Wrong answer0/0182ms29632 KiB
3Runtime error0/329ms20796 KiB
4Accepted3/328ms21684 KiB
5Wrong answer0/327ms22128 KiB
6Accepted3/328ms22328 KiB
7Wrong answer0/328ms22428 KiB
8Wrong answer0/428ms22704 KiB
9Wrong answer0/428ms23020 KiB
10Wrong answer0/428ms23836 KiB
11Wrong answer0/437ms25216 KiB
12Wrong answer0/439ms26388 KiB
13Wrong answer0/434ms25316 KiB
14Wrong answer0/435ms25560 KiB
15Wrong answer0/441ms26604 KiB
16Runtime error0/428ms24000 KiB
17Runtime error0/428ms24080 KiB
18Runtime error0/429ms24512 KiB
19Wrong answer0/4168ms33328 KiB
20Runtime error0/428ms24880 KiB
21Runtime error0/428ms24924 KiB
22Runtime error0/428ms24976 KiB