33822023-02-27 11:49:46BenedekÁruszállítás üres szakaszaicsharpWrong answer 4/50279ms36764 KiB
using System;
using System.Linq;

namespace Áruszállításüreszakaszai
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = st[0];
            int m = st[1];

            int[] p = new int[2 * m];
            int[] k = new int[2 * m];
            int pi = 0;

            for (int i = 0; i < m; i++)
            {
                st = Console.ReadLine().Split().Select(int.Parse).ToArray();

                p[pi] = st[0];
                k[pi] = 0;
                pi++;
                p[pi] = st[1] - 1;
                k[pi] = 1;
                pi++;


            }
            Array.Sort(p, k);
            int kezdo = 0;
            int vegzo = 0;
            int db = 0;
            for (int i = 0; i < p.Length; i++)
            {
                if (k[i] == 0)
                {
                    kezdo++;

                }
                else
                {
                    vegzo++;
                }

                if (kezdo == vegzo)
                {
                    db++;
                }


            }
            if (p[0] != 1)
            {
                db++;
            }
            if (p[m *2 -1] == N + 1)
            {
                db--;
            }

            Console.WriteLine(db);
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/032ms22448 KiB
2Wrong answer0/0279ms33788 KiB
3Accepted2/232ms23052 KiB
4Wrong answer0/234ms23420 KiB
5Wrong answer0/234ms23824 KiB
6Wrong answer0/234ms24100 KiB
7Accepted2/235ms24360 KiB
8Wrong answer0/234ms24768 KiB
9Wrong answer0/234ms25132 KiB
10Wrong answer0/234ms25132 KiB
11Wrong answer0/234ms24880 KiB
12Wrong answer0/234ms25312 KiB
13Wrong answer0/346ms28336 KiB
14Wrong answer0/352ms29716 KiB
15Wrong answer0/346ms28284 KiB
16Wrong answer0/3214ms36044 KiB
17Wrong answer0/3215ms36080 KiB
18Wrong answer0/3240ms36388 KiB
19Wrong answer0/352ms30040 KiB
20Wrong answer0/356ms30508 KiB
21Wrong answer0/3250ms36484 KiB
22Wrong answer0/3264ms36764 KiB