80622024-01-12 11:45:03David9320Bejgli (80 pont)cpp17Accepted 80/8037ms14156 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<int> szeletek(n);
    vector<int> hosszak(1e6);
    int szam = 0;
    int legtobb = 0;
    int legtobbi = 0;

    for(int i = 0; i < n; i++) {
        cin >> szeletek[i];
    }

    for(int i = 0; i < n; i++) {
        szam++;
        hosszak[szeletek[i]]++;
        if(hosszak[szeletek[i]] > legtobb) {
            legtobb = hosszak[szeletek[i]];
            legtobbi = szeletek[i];
        }
        i += szeletek[i] - 1;
    }

    cout << szam << endl;
    cout << legtobbi << endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/06ms9536 KiB
2Accepted0/06ms9816 KiB
3Accepted4/46ms9948 KiB
4Accepted4/46ms10160 KiB
5Accepted4/46ms10120 KiB
6Accepted4/46ms10128 KiB
7Accepted4/46ms10440 KiB
8Accepted4/46ms10588 KiB
9Accepted4/46ms10756 KiB
10Accepted4/46ms10904 KiB
11Accepted4/47ms10824 KiB
12Accepted4/47ms10836 KiB
13Accepted4/47ms10972 KiB
14Accepted4/48ms11000 KiB
15Accepted4/48ms11028 KiB
16Accepted4/49ms11236 KiB
17Accepted4/416ms11780 KiB
18Accepted4/423ms12396 KiB
19Accepted4/429ms12780 KiB
20Accepted4/430ms13160 KiB
21Accepted4/437ms13896 KiB
22Accepted4/426ms14156 KiB