76072024-01-10 08:57:45TortelliniJrA lehető legkevesebb átszállás (50 pont)csharpRuntime error 28/50200ms77540 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LegkAtsz
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            List<int>[] allelerh = new List<int>[inp[1] + 1];
            int[,] vonk = new int[inp[0] + 1, 2];
            int von = inp[0];
            int all = inp[1];
            for (int i = 1; i <= all; i++)
            {
                allelerh[i] = new List<int>();
            }
            for (int i = 1; i <= von; i++)
            {
                inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int u = inp[0]; u <= inp[1]; u++)
                {
                    allelerh[u].Add(i);
                }
                vonk[i, 0] = inp[0];
                vonk[i, 1] = inp[1];
            }
            int jel = 1;
            int locmax = 0;
            int locmaxn = 0;
            List<int> sol = new List<int>();
            while (jel != all)
            {
                for (int i = 0; i < allelerh[jel].Count; i++)
                {
                    if (vonk[allelerh[jel][i], 1] > locmax)
                    {
                        locmax = vonk[allelerh[jel][i], 1];
                        locmaxn = allelerh[jel][i];
                    }
                }
                jel = locmax;
                locmax = 0;
                sol.Add(locmaxn);
            }
            Console.WriteLine(sol.Count - 1);
            foreach (var item in sol)
            {
                Console.Write(item + " ");
            }
            Console.ReadLine();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base28/50
1Accepted0/034ms22044 KiB
2Accepted0/0164ms73904 KiB
3Runtime error0/1200ms77540 KiB
4Runtime error0/1159ms77044 KiB
5Accepted2/234ms23688 KiB
6Accepted2/234ms23992 KiB
7Accepted2/248ms36252 KiB
8Accepted2/250ms36224 KiB
9Accepted2/254ms36000 KiB
10Accepted2/264ms40688 KiB
11Accepted2/279ms49464 KiB
12Accepted2/293ms54372 KiB
13Accepted2/250ms37964 KiB
14Accepted2/264ms43636 KiB
15Accepted2/275ms47864 KiB
16Accepted2/290ms54980 KiB
17Accepted2/2128ms67780 KiB
18Accepted2/2134ms67792 KiB
19Runtime error0/2155ms74456 KiB
20Runtime error0/2137ms74400 KiB
21Runtime error0/2143ms74308 KiB
22Runtime error0/2143ms74080 KiB
23Runtime error0/2103ms74288 KiB
24Runtime error0/2108ms74020 KiB
25Runtime error0/2101ms73824 KiB
26Runtime error0/2104ms73836 KiB
27Runtime error0/2107ms73512 KiB
28Runtime error0/296ms73348 KiB