33772023-02-27 11:43:36BenedekÁruszállítás üres szakaszaicsharpWrong answer 7/50275ms36516 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--;
            }
            if (p[m * 2 - 1] != N)
            {
                db++;
            }
            Console.WriteLine(db);
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base7/50
1Accepted0/032ms22280 KiB
2Wrong answer0/0275ms33540 KiB
3Wrong answer0/232ms22812 KiB
4Wrong answer0/232ms22804 KiB
5Accepted2/232ms23028 KiB
6Wrong answer0/232ms22980 KiB
7Wrong answer0/232ms23476 KiB
8Accepted2/232ms23532 KiB
9Wrong answer0/232ms23428 KiB
10Wrong answer0/235ms23728 KiB
11Wrong answer0/234ms24064 KiB
12Wrong answer0/234ms24352 KiB
13Wrong answer0/348ms27648 KiB
14Wrong answer0/352ms28896 KiB
15Wrong answer0/346ms27716 KiB
16Wrong answer0/3215ms35300 KiB
17Wrong answer0/3216ms35624 KiB
18Wrong answer0/3246ms36020 KiB
19Wrong answer0/354ms29728 KiB
20Wrong answer0/357ms30256 KiB
21Accepted3/3254ms35872 KiB
22Wrong answer0/3264ms36516 KiB