33712023-02-27 11:27:17tothgergelyÁruszállítás üres szakaszaicsharpWrong answer 13/50284ms36440 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    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 kezd = 0;
            int veg = 0;
            int db = 0;
            for (int i = 0; i < p.Length; i++)
            {
                if (k[i] == 0)
                {
                    kezd++;
                }
                else 
                {
                    veg++;
                }
                if (kezd == veg)
                {
                    db++;
                }
                
            }
            if (p[0] != 1)
            {
                db++;
            }
            else if (p[p.Length - 1] == n + 1)
            {
                db--;
            }
            Console.WriteLine(db);
            Console.ReadKey();


        }
    }
}
SubtaskSumTestVerdictTimeMemory
base13/50
1Accepted0/035ms22556 KiB
2Wrong answer0/0284ms33592 KiB
3Accepted2/234ms22564 KiB
4Accepted2/234ms23140 KiB
5Wrong answer0/234ms23436 KiB
6Accepted2/234ms23672 KiB
7Accepted2/234ms23784 KiB
8Wrong answer0/232ms24284 KiB
9Wrong answer0/234ms24620 KiB
10Wrong answer0/234ms24700 KiB
11Accepted2/234ms24984 KiB
12Wrong answer0/235ms25484 KiB
13Wrong answer0/348ms28276 KiB
14Wrong answer0/354ms29292 KiB
15Wrong answer0/346ms27624 KiB
16Wrong answer0/3209ms35608 KiB
17Wrong answer0/3214ms35716 KiB
18Wrong answer0/3239ms36440 KiB
19Wrong answer0/357ms30080 KiB
20Wrong answer0/357ms30100 KiB
21Accepted3/3261ms36300 KiB
22Wrong answer0/3264ms36368 KiB