33702023-02-27 11:24:32tothgergelyÁruszállítás üres szakaszaicsharpWrong answer 13/50275ms36888 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/034ms22340 KiB
2Wrong answer0/0275ms33504 KiB
3Accepted2/235ms23092 KiB
4Accepted2/232ms23516 KiB
5Wrong answer0/232ms23152 KiB
6Accepted2/232ms23312 KiB
7Accepted2/235ms23632 KiB
8Wrong answer0/235ms23968 KiB
9Wrong answer0/232ms23856 KiB
10Wrong answer0/235ms24260 KiB
11Accepted2/232ms25016 KiB
12Wrong answer0/234ms25036 KiB
13Wrong answer0/350ms28020 KiB
14Wrong answer0/354ms29256 KiB
15Wrong answer0/346ms27964 KiB
16Wrong answer0/3211ms35664 KiB
17Wrong answer0/3216ms35784 KiB
18Wrong answer0/3254ms36176 KiB
19Wrong answer0/357ms30320 KiB
20Wrong answer0/359ms30532 KiB
21Accepted3/3259ms36356 KiB
22Wrong answer0/3270ms36888 KiB