33552023-02-27 10:52:31tothgergelyÁruszállítás üres szakaszaicsharpWrong answer 13/50289ms36468 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/034ms22744 KiB
2Wrong answer0/0289ms33528 KiB
3Accepted2/234ms22952 KiB
4Accepted2/234ms23404 KiB
5Wrong answer0/234ms23540 KiB
6Accepted2/232ms23956 KiB
7Accepted2/235ms23844 KiB
8Wrong answer0/234ms24240 KiB
9Wrong answer0/234ms24472 KiB
10Wrong answer0/234ms24636 KiB
11Accepted2/234ms24944 KiB
12Wrong answer0/235ms25704 KiB
13Wrong answer0/348ms28276 KiB
14Wrong answer0/352ms29520 KiB
15Wrong answer0/346ms27728 KiB
16Wrong answer0/3209ms35808 KiB
17Wrong answer0/3221ms35908 KiB
18Wrong answer0/3243ms36372 KiB
19Wrong answer0/354ms29812 KiB
20Wrong answer0/357ms30516 KiB
21Accepted3/3252ms36196 KiB
22Wrong answer0/3259ms36468 KiB