33652023-02-27 11:21:39BenedekÁruszállítás üres szakaszaicsharpWrong answer 26/50273ms37060 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
base26/50
1Accepted0/034ms22472 KiB
2Accepted0/0273ms33768 KiB
3Accepted2/235ms23412 KiB
4Accepted2/234ms23296 KiB
5Wrong answer0/234ms24084 KiB
6Accepted2/234ms24192 KiB
7Accepted2/234ms24596 KiB
8Wrong answer0/235ms24744 KiB
9Accepted2/234ms24692 KiB
10Accepted2/234ms24740 KiB
11Accepted2/234ms24796 KiB
12Wrong answer0/235ms25436 KiB
13Wrong answer0/348ms28528 KiB
14Wrong answer0/354ms29832 KiB
15Wrong answer0/346ms27844 KiB
16Accepted3/3209ms36440 KiB
17Accepted3/3214ms36320 KiB
18Accepted3/3241ms36924 KiB
19Wrong answer0/354ms30748 KiB
20Wrong answer0/357ms30980 KiB
21Wrong answer0/3250ms37060 KiB
22Accepted3/3266ms37028 KiB