34082023-02-27 13:21:49vááááÁruszállítás üres szakaszaicsharpTime limit exceeded 18/50358ms36944 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;
            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 == 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 (ck ==cv)
                    ures++;
                if(ures == 2 && fures == false)
                {
                        fures = true;
                        ki++;
                }
                else if (fures == true && ures != 2)
                    fures = false;
                k++;
            }
            Console.WriteLine(ki);
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base18/50
1Accepted0/030ms21036 KiB
2Time limit exceeded0/0358ms33136 KiB
3Accepted2/230ms21692 KiB
4Accepted2/230ms22120 KiB
5Wrong answer0/232ms22608 KiB
6Wrong answer0/232ms22696 KiB
7Accepted2/230ms22992 KiB
8Wrong answer0/229ms23208 KiB
9Accepted2/229ms23320 KiB
10Accepted2/230ms23348 KiB
11Accepted2/232ms23256 KiB
12Wrong answer0/234ms23632 KiB
13Wrong answer0/350ms27480 KiB
14Wrong answer0/359ms29064 KiB
15Wrong answer0/350ms27008 KiB
16Accepted3/3282ms36236 KiB
17Accepted3/3287ms36236 KiB
18Time limit exceeded0/3314ms36420 KiB
19Wrong answer0/367ms29292 KiB
20Wrong answer0/371ms29848 KiB
21Time limit exceeded0/3333ms36504 KiB
22Time limit exceeded0/3340ms36944 KiB