93712024-02-21 10:20:58Leventusz09Leghosszabb béke (75 pont)csharpTime limit exceeded 9/75280ms28312 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[] in2;

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

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

            for(int i=0, l = 0; i<N; i++){
                if (Ds[i]){
                    if (l > o1) {
                        o1 = l;
                        o2 = i - o1;
                    }
                    l = 0;
                }else{
                    l++;
                }
            }

            Console.WriteLine("{0} {1}", o1, o2+1);
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base9/75
1Accepted0/034ms22312 KiB
2Time limit exceeded0/0261ms7960 KiB
3Accepted3/332ms23484 KiB
4Accepted3/334ms23564 KiB
5Wrong answer0/334ms23920 KiB
6Accepted3/334ms23832 KiB
7Wrong answer0/334ms23752 KiB
8Wrong answer0/432ms23592 KiB
9Wrong answer0/434ms24048 KiB
10Wrong answer0/435ms24428 KiB
11Wrong answer0/463ms27300 KiB
12Wrong answer0/496ms28312 KiB
13Wrong answer0/475ms26908 KiB
14Wrong answer0/481ms27300 KiB
15Wrong answer0/496ms28148 KiB
16Time limit exceeded0/4266ms7996 KiB
17Time limit exceeded0/4280ms7816 KiB
18Time limit exceeded0/4240ms7504 KiB
19Time limit exceeded0/4252ms8368 KiB
20Time limit exceeded0/4264ms7072 KiB
21Time limit exceeded0/4277ms7112 KiB
22Time limit exceeded0/4268ms7900 KiB