34062023-02-27 13:04:17vááááÁruszállítás üres szakaszaicsharpTime limit exceeded 12/50372ms37720 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]);
            List<int> kez = new List<int>();
            List<int> veg = new List<int>();
            for (int i = 0; i < M; i++)
            {
                a = Console.ReadLine();
                kez.Add(int.Parse(a.Split()[0]));
                veg.Add(int.Parse(a.Split()[1]));
            }
            kez.Sort();
            veg.Sort();
            int ck = 0, cv = 0;
            bool stop = true;
            int ures = 0;
            bool fures = false;
            int k = 1;
            int ki = 0;
            while(true)
            {
                if (k == N + 1)
                    break;
                ures = 0;
                if (ck == cv)
                    ures++;
                while (true)
                {
                    if (ck == kez.Count())
                        break;
                    if (kez[ck] == k && ck <= kez.Count)
                    {
                        ck++;
                    }
                    if (ck != kez.Count())
                    {
                        if (kez[ck] != k)
                            break;
                    }
                }
                while (true)
                {
                    if (cv == veg.Count())
                        break;
                    if (veg[cv] == k && cv<=veg.Count)
                    {
                        cv++;
                    }
                    if (cv != veg.Count)
                    {
                        if (veg[cv] != k && cv <= veg.Count)
                            break;
                    }
                }
                if (ck ==cv)
                    ures++;
                if(ures == 2 && fures == false)
                {
                        fures = true;
                        ki++;
                }
                if (fures == true && ures != 2)
                    fures = false;
                k++;
            }
            Console.WriteLine(ki);
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base12/50
1Accepted0/032ms21688 KiB
2Time limit exceeded0/0370ms11424 KiB
3Accepted2/229ms22884 KiB
4Accepted2/229ms23128 KiB
5Wrong answer0/232ms23548 KiB
6Wrong answer0/232ms24008 KiB
7Accepted2/232ms24340 KiB
8Wrong answer0/232ms24524 KiB
9Accepted2/232ms25152 KiB
10Accepted2/232ms25176 KiB
11Accepted2/235ms25348 KiB
12Wrong answer0/239ms25644 KiB
13Wrong answer0/356ms28952 KiB
14Wrong answer0/364ms30132 KiB
15Wrong answer0/359ms28684 KiB
16Time limit exceeded0/3308ms37668 KiB
17Time limit exceeded0/3326ms37720 KiB
18Time limit exceeded0/3342ms14680 KiB
19Wrong answer0/378ms31144 KiB
20Wrong answer0/393ms31756 KiB
21Time limit exceeded0/3354ms14740 KiB
22Time limit exceeded0/3372ms14856 KiB