33742023-02-27 11:37:18tothgergelyÁruszállítás üres szakaszaicsharpWrong answer 26/50277ms36580 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++;
            }
            if (p[m * 2 - 1] == n + 1)
            {
                db--;
            }
            Console.WriteLine(db);
            Console.ReadKey();


        }
    }
}
SubtaskSumTestVerdictTimeMemory
base26/50
1Accepted0/035ms22264 KiB
2Accepted0/0277ms33440 KiB
3Accepted2/234ms23044 KiB
4Accepted2/232ms23400 KiB
5Wrong answer0/232ms23524 KiB
6Accepted2/234ms23504 KiB
7Accepted2/234ms23768 KiB
8Wrong answer0/232ms23964 KiB
9Accepted2/234ms24704 KiB
10Accepted2/234ms24892 KiB
11Accepted2/235ms24980 KiB
12Wrong answer0/234ms25524 KiB
13Wrong answer0/346ms28552 KiB
14Wrong answer0/352ms29656 KiB
15Wrong answer0/346ms28168 KiB
16Accepted3/3212ms36124 KiB
17Accepted3/3216ms36072 KiB
18Accepted3/3247ms36464 KiB
19Wrong answer0/352ms30364 KiB
20Wrong answer0/356ms30668 KiB
21Wrong answer0/3254ms36456 KiB
22Accepted3/3263ms36580 KiB