110322024-06-26 19:10:12KarolinaBejgli (80 pont)cpp17Accepted 80/8034ms2048 KiB
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++)
	{
		cin >> vec[i];
	}
	vector<int> ve(0);
	int a = 0;
	int b = 0;
	int szelet = 0;
	while (n>0)
	{
		b=vec[a];
		n=n - b;
		a=a + b;
		szelet++;
		ve.push_back(b);
	}
	cout << szelet;
	int ln = 0;
	for (int i = 0; i < ve.size(); i++)
	{
		if (ln < ve[i])
		{
			ln = ve[i];
		}
		
	}
	vector<vector<int>>	v(ln + 1);
	for (int i = 0; i < ve.size(); i++)
	{
		v[ve[i]].push_back(ve[i]);

	}
	int legn = 0;
	int hely = 0;
	for (int i = 0; i < v.size(); i++)
	{
	
		if (legn < v[i].size())
		{
			legn = v[i].size();
			hely = i;
		}
	
	}
	cout << '\n' << hely;
	
}

SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/03ms560 KiB
2Accepted0/03ms356 KiB
3Accepted4/43ms612 KiB
4Accepted4/43ms396 KiB
5Accepted4/42ms356 KiB
6Accepted4/43ms384 KiB
7Accepted4/43ms504 KiB
8Accepted4/43ms356 KiB
9Accepted4/43ms384 KiB
10Accepted4/43ms356 KiB
11Accepted4/43ms356 KiB
12Accepted4/43ms504 KiB
13Accepted4/44ms356 KiB
14Accepted4/44ms500 KiB
15Accepted4/46ms504 KiB
16Accepted4/46ms632 KiB
17Accepted4/413ms664 KiB
18Accepted4/421ms2048 KiB
19Accepted4/427ms1256 KiB
20Accepted4/427ms1180 KiB
21Accepted4/434ms2044 KiB
22Accepted4/425ms1256 KiB