34252023-02-27 14:03:22vááááÁruszállítás üres szakaszaicsharpTime limit exceeded 14/50338ms34096 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace aruszallitas
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            int N = int.Parse(a.Split()[0]);
            int M = int.Parse(a.Split()[1]);
            int[] kez = new int[M];
            int[] veg = new int[M];
            for (int i = 0; i < M; i++)
            {
                a = Console.ReadLine();
                kez[i] = (int.Parse(a.Split()[0]));
                veg[i] = (int.Parse(a.Split()[1]));
            }
            Array.Sort(kez);
            Array.Sort(veg);
            int ck = 0, cv = 0;
            int ures = 0;
            bool fures = false;
            int ki = 0;
            bool kozt = false;
            for (int k = 1;  k < N+2;  k++)
            {
                ures = 0;
                if (ck == cv)
                    ures++;
                while (true)
                {
                    if (ck == M)
                        break;
                    if (kez[ck] == k)
                    {
                        ck++;
                    }
                    if (ck != M)
                    {
                        if (kez[ck] != k)
                            break;
                    }
                }
                while (true)
                {
                    if (cv == M)
                        break;
                    if (veg[cv] == k)
                    {
                        cv++;
                    }
                    if (cv != M)
                    {
                        if (veg[cv] != k)
                            break;
                    }
                }
                if (kozt && ck != cv && fures == false)
                {
                    ki++;
                }
                kozt = false;
                if (ck ==cv)
                {
                    kozt = true;
                    ures++;
                }
                if(ures == 2 && fures == false)
                {
                        fures = true;
                        ki++;
                }
                else if (fures == true && ures != 2)
                    fures = false;
            }
            Console.WriteLine(ki);
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/028ms20752 KiB
2Time limit exceeded0/0338ms30548 KiB
3Accepted2/228ms21280 KiB
4Wrong answer0/228ms21764 KiB
5Accepted2/230ms22344 KiB
6Accepted2/230ms22756 KiB
7Accepted2/230ms23004 KiB
8Accepted2/230ms23268 KiB
9Wrong answer0/230ms23920 KiB
10Wrong answer0/230ms23768 KiB
11Accepted2/230ms23824 KiB
12Accepted2/232ms24484 KiB
13Wrong answer0/348ms27356 KiB
14Wrong answer0/357ms28736 KiB
15Wrong answer0/348ms27228 KiB
16Wrong answer0/3264ms33468 KiB
17Wrong answer0/3282ms33976 KiB
18Time limit exceeded0/3305ms34096 KiB
19Wrong answer0/363ms29432 KiB
20Wrong answer0/364ms30128 KiB
21Time limit exceeded0/3319ms33716 KiB
22Time limit exceeded0/3338ms33848 KiB