48662023-04-03 08:37:14barsibotondBejgli (80 pont)csharpPartially correct 16/80595ms70336 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/028ms20376 KiB
2Accepted0/028ms20944 KiB
3Partially correct2/427ms21044 KiB
4Partially correct2/427ms21320 KiB
5Partially correct2/428ms21552 KiB
6Runtime error0/432ms22108 KiB
7Accepted4/441ms25420 KiB
8Accepted4/493ms31332 KiB
9Partially correct2/4345ms70336 KiB
10Time limit exceeded0/4589ms28464 KiB
11Time limit exceeded0/4568ms31616 KiB
12Time limit exceeded0/4559ms28656 KiB
13Time limit exceeded0/4556ms32344 KiB
14Time limit exceeded0/4574ms32108 KiB
15Time limit exceeded0/4595ms32748 KiB
16Time limit exceeded0/4574ms29980 KiB
17Time limit exceeded0/4558ms33392 KiB
18Time limit exceeded0/4583ms34984 KiB
19Time limit exceeded0/4575ms35564 KiB
20Time limit exceeded0/4560ms36016 KiB
21Time limit exceeded0/4570ms36356 KiB
22Time limit exceeded0/4577ms34708 KiB