48652023-04-03 08:35:42barsibotondBejgli (80 pont)csharpPartially correct 16/80600ms70012 KiB
using System;

namespace bejgli
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string alma = Console.ReadLine();
            int[] nem = new int[n];
            for (int i = 0; i < n; i++)
            {
                nem[i] = int.Parse(alma.Split()[i]);
            }
            int[] igen = new int[n];
            for (int i = 0; i < n; i++)
            {
                igen[i] = 0;
            }
            int a = 0;
            for (int i = 0; i < n;)
            {
                igen[a] = nem[i];
                a++;
                i = i + nem[i];
            }
            int b = 0;
            for (int i = 0; i < n; i++)
            {
                if (igen[i] > 0)
                    b++;
            }
            Console.WriteLine(b);
            int[] talan = new int[n];
            for (int i = 0; i < n; i++)
            {
                talan[i] = 0;
            }
            for (int i = 0; i < n; i++)
            {
                if(talan[igen[i]]>0)
                    talan[igen[i] - 1]++;
            }
            int[] lehet = new int[n];
            for (int i = 0; i < n; i++)
            {
                lehet[i] = talan[i];
            }
            int max = 0;
            for (int i = 0; i < n-1; i++)
            {
                if (lehet[i] > max)
                {
                    max = lehet[i];
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (lehet[i] == max)
                {
                    Console.WriteLine(i+1);
                    break;
                }
            }
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base16/80
1Accepted0/028ms20284 KiB
2Accepted0/028ms21048 KiB
3Partially correct2/427ms21064 KiB
4Partially correct2/428ms21560 KiB
5Partially correct2/427ms21868 KiB
6Runtime error0/432ms21988 KiB
7Accepted4/441ms25236 KiB
8Accepted4/492ms31428 KiB
9Partially correct2/4347ms70012 KiB
10Time limit exceeded0/4574ms28212 KiB
11Time limit exceeded0/4600ms31376 KiB
12Time limit exceeded0/4569ms28792 KiB
13Time limit exceeded0/4574ms32424 KiB
14Time limit exceeded0/4569ms32980 KiB
15Time limit exceeded0/4583ms33304 KiB
16Time limit exceeded0/4579ms30456 KiB
17Time limit exceeded0/4578ms34752 KiB
18Time limit exceeded0/4592ms35872 KiB
19Time limit exceeded0/4583ms36816 KiB
20Time limit exceeded0/4583ms36736 KiB
21Time limit exceeded0/4572ms36832 KiB
22Time limit exceeded0/4584ms35664 KiB