46762023-03-30 21:27:54csicsilla70Leghosszabb béke (75 pont)csharpTime limit exceeded 24/75280ms23444 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace leghosszabb_beke
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] sor = Console.ReadLine().Split();
            int napok = int.Parse(sor[0]);
            int n = int.Parse(sor[1]);
            bool[] x = new bool[napok + 1];
            for (int i = 0; i < n; i++)
            {
                sor = Console.ReadLine().Split();
                for (int j = int.Parse(sor[0]); j <= int.Parse(sor[1]); j++)
                {
                    x[j] = true;
                }
            }
            int kezd = 0, hossz = 0, mhossz = 0, mindex = 0;
            int k = 1;
            while (k <= napok)
            {
                while (k <= napok && x[k]) k++;
                kezd = k;
                while (k <= napok && !x[k]) k++;
                hossz = k - kezd;
                if (hossz > mhossz)
                {
                    mhossz = hossz;
                    mindex = kezd;
                }
            }
            Console.WriteLine(mhossz + " " + mindex);
            Console.ReadKey();
        } 
    }
}
SubtaskSumTestVerdictTimeMemory
base24/75
1Accepted0/028ms20504 KiB
2Time limit exceeded0/0268ms4424 KiB
3Wrong answer0/327ms21176 KiB
4Accepted3/327ms21792 KiB
5Accepted3/327ms22152 KiB
6Accepted3/327ms21908 KiB
7Accepted3/327ms22392 KiB
8Accepted4/427ms22800 KiB
9Accepted4/432ms23220 KiB
10Accepted4/475ms23444 KiB
11Time limit exceeded0/4263ms7016 KiB
12Time limit exceeded0/4250ms7068 KiB
13Time limit exceeded0/4277ms7236 KiB
14Time limit exceeded0/4268ms7168 KiB
15Time limit exceeded0/4264ms7204 KiB
16Time limit exceeded0/4273ms7124 KiB
17Time limit exceeded0/4273ms6940 KiB
18Time limit exceeded0/4277ms6832 KiB
19Time limit exceeded0/4280ms6840 KiB
20Time limit exceeded0/4245ms6908 KiB
21Time limit exceeded0/4268ms6836 KiB
22Time limit exceeded0/4252ms6824 KiB