48602023-04-03 08:17:46vááááBejgli (80 pont)csharpAccepted 80/8085ms42244 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace bejgli2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] bejgli = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ki = 0, max = int.MinValue,id=-1;
            int[] alma = new int[n+1];
            for (int i = 0; i < n+1; i++)
            {
                alma[i] = 0;
            }
            for (int i = 0; i < n; i++)
            {
                alma[bejgli[i]]++;
                i += bejgli[i] - 1;
            }
            for (int i = 0; i < n+1; i++)
            {
                if (alma[i] != 0) ki += alma[i];
                if(max < alma[i])
                {
                    max = alma[i];
                    id = i;
                }
            }
            Console.WriteLine(ki);
            Console.WriteLine(id);
            Console.ReadLine();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/029ms22072 KiB
2Accepted0/029ms22264 KiB
3Accepted4/432ms22652 KiB
4Accepted4/430ms23124 KiB
5Accepted4/430ms23636 KiB
6Accepted4/430ms24044 KiB
7Accepted4/435ms24900 KiB
8Accepted4/435ms24872 KiB
9Accepted4/435ms25532 KiB
10Accepted4/435ms25844 KiB
11Accepted4/437ms26056 KiB
12Accepted4/437ms26540 KiB
13Accepted4/439ms27248 KiB
14Accepted4/439ms28244 KiB
15Accepted4/441ms29060 KiB
16Accepted4/443ms29180 KiB
17Accepted4/456ms33332 KiB
18Accepted4/475ms37896 KiB
19Accepted4/479ms40960 KiB
20Accepted4/479ms41160 KiB
21Accepted4/485ms42244 KiB
22Accepted4/479ms39608 KiB