40322023-03-09 13:27:32KristófBejgli (80 pont)cpp11Accepted 80/8032ms5700 KiB
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int h[n+1];
    int b[n];
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n+1;i++){
        h[i]=0;
    }
    int szamlalo=0;
    for(int i=0;i<n;i++){
            h[b[i]]++;

        szamlalo++;
        i+=b[i]-1;
    }
    int maxi=0;
    int in=0;
    for(int i=0;i<n+1;i++){
        if(h[i]>maxi){
            maxi=h[i];
            in=i;
        }
    }
    cout<<szamlalo<<endl;
    cout<<in;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/03ms1872 KiB
2Accepted0/03ms2068 KiB
3Accepted4/42ms2148 KiB
4Accepted4/43ms2404 KiB
5Accepted4/42ms2616 KiB
6Accepted4/43ms2828 KiB
7Accepted4/42ms2932 KiB
8Accepted4/42ms3008 KiB
9Accepted4/43ms3136 KiB
10Accepted4/43ms3232 KiB
11Accepted4/43ms3220 KiB
12Accepted4/44ms3516 KiB
13Accepted4/44ms3484 KiB
14Accepted4/44ms3472 KiB
15Accepted4/46ms3804 KiB
16Accepted4/46ms4064 KiB
17Accepted4/413ms4700 KiB
18Accepted4/420ms5604 KiB
19Accepted4/427ms5648 KiB
20Accepted4/427ms5700 KiB
21Accepted4/432ms5616 KiB
22Accepted4/421ms5700 KiB