35052023-02-28 13:45:59vááááTalálkozáscsharpTime limit exceeded 41/55252ms33308 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace találka
{
    class Program
    {
        static void Main(string[] args)
        {
            double n = Convert.ToDouble(Console.ReadLine());
            int[] be = new int[100001];
            int[] ki = new int[100001];
            string a;
            int bek;
            int kik;
            int max = 0;
            for (int i = 0; i < n; i++)
            {
                a = Console.ReadLine();
                bek = int.Parse(a.Split()[0]);
                kik = int.Parse(a.Split()[1]);
                if (be[bek] == 0) be[bek] = 1;
                else be[bek]++;
                if (ki[kik] == 0) ki[kik] = 1;
                else ki[kik]++;
                if (max < kik) max = kik + 1;
            }
            be[0] = 0;
            ki[0] = 0;
            int k = 0, v = 0, jk = 0, jv = 0, mint = int.MaxValue, bent = 0, benttemp = 0; ;
            bool volt = false;
            while(true)
            {
                if (v > max-2) break;
                v++;
                bent += be[v];
                int j = 2;
                while(bent >= n/2)
                {
                    volt = true;
                    k++;
                    benttemp = bent;
                    bent -= ki[k - 1];
                }
                if(volt)
                {
                    k--;
                    volt = false;
                    bent = benttemp;
                    if(mint > v - k)
                    {
                        jk = k;
                        jv = v;
                        mint = v - k;

                    }
                }
            }
            Console.WriteLine(mint+1);
            Console.WriteLine(jk + " " + jv);
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base41/55
1Accepted0/030ms21836 KiB
2Time limit exceeded0/0252ms30360 KiB
3Wrong answer0/230ms22636 KiB
4Accepted2/229ms22908 KiB
5Accepted2/229ms23380 KiB
6Accepted2/229ms23728 KiB
7Accepted2/230ms23604 KiB
8Accepted3/329ms24004 KiB
9Accepted3/329ms24016 KiB
10Accepted3/329ms24136 KiB
11Accepted3/343ms27232 KiB
12Accepted3/352ms29052 KiB
13Accepted3/352ms29224 KiB
14Accepted3/371ms32320 KiB
15Accepted3/371ms32244 KiB
16Accepted3/371ms32088 KiB
17Accepted3/371ms32404 KiB
18Accepted3/3100ms32336 KiB
19Time limit exceeded0/3252ms32312 KiB
20Time limit exceeded0/3243ms32832 KiB
21Time limit exceeded0/3247ms33156 KiB
22Time limit exceeded0/3248ms33308 KiB