93762024-02-21 10:39:09Leventusz09Leghosszabb béke (75 pont)csharpTime limit exceeded 15/75301ms38192 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[] in1 = Console.ReadLine().Split();
            int N = int.Parse(in1[0]),
                M = int.Parse(in1[1]);

            //bool[] Ds = new bool[N];
            int[] A = new int[M], B = new int[M];
            int[] in2;

            for(int i=0; i<M; i++){
                in2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
                A[i] = in2[0];
                B[i] = in2[1];
            }
            int o1 = 0, o2 = 0;

            //if (Ds.Min()) { Console.WriteLine(-1); return; }

            for(int i=0, j, l=0; i<N; i++){
                for(j=0; j<M; j++){
                    if (A[j] <= i && i <= B[j]) break;
                }
                if (j == M){
                    l++;
                    if (l > o1){
                        o1 = l;
                        o2 = i - o1;
                    }
                }else{
                    l = 0;
                }
            }
            if (o1 == 0) Console.WriteLine(-1); else
            Console.WriteLine("{0} {1}", o1, o2+1);

        }
    }
}
SubtaskSumTestVerdictTimeMemory
base15/75
1Accepted0/032ms22380 KiB
2Time limit exceeded0/0254ms10784 KiB
3Wrong answer0/330ms23360 KiB
4Wrong answer0/330ms23500 KiB
5Wrong answer0/329ms23336 KiB
6Accepted3/332ms23564 KiB
7Wrong answer0/332ms24340 KiB
8Wrong answer0/432ms24560 KiB
9Wrong answer0/432ms25028 KiB
10Wrong answer0/434ms25620 KiB
11Wrong answer0/465ms28384 KiB
12Wrong answer0/4105ms29564 KiB
13Wrong answer0/481ms27916 KiB
14Wrong answer0/486ms29192 KiB
15Wrong answer0/4105ms29952 KiB
16Accepted4/4136ms29816 KiB
17Accepted4/4172ms30020 KiB
18Accepted4/450ms30804 KiB
19Time limit exceeded0/4301ms14832 KiB
20Time limit exceeded0/4273ms15480 KiB
21Time limit exceeded0/4215ms38192 KiB
22Time limit exceeded0/4301ms17512 KiB