40162023-03-09 08:13:42kdbBejgli (80 pont)cpp17Wrong answer 44/8012ms4140 KiB
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int>vec(n + 2);
    for (int i = 0; i < n; i++) cin >> vec[i + 1];
    int db = 0;
    unordered_map<int, int>m;
    for (int i = 0; i < n + 1; i++)
    {
        if (vec[i] != vec[i + 1] && vec[i] != 0)
        {
            db++;
            m[vec[i]]++;
        }
        else if (vec[i] == 1 && vec[i + 1] == 1)
        {
            db++;
            m[vec[i]]++;
        }
    }
    int maxi = 0, mh = 0;
    for (auto i : m)
    {
        if (i.second > maxi)
        {
            maxi = i.second;
            mh = i.first;
        }
    }
    cout << db << endl << mh << endl;
    return 0;
}
/*
7
1 1 3 3 3 2 2
*/
SubtaskSumTestVerdictTimeMemory
base44/80
1Accepted0/03ms1832 KiB
2Wrong answer0/03ms2020 KiB
3Accepted4/42ms2100 KiB
4Accepted4/42ms2232 KiB
5Partially correct2/42ms2440 KiB
6Accepted4/42ms2556 KiB
7Accepted4/42ms2532 KiB
8Partially correct2/42ms2476 KiB
9Partially correct2/43ms2624 KiB
10Partially correct2/43ms2856 KiB
11Partially correct2/43ms2852 KiB
12Wrong answer0/43ms2952 KiB
13Partially correct2/43ms3128 KiB
14Partially correct2/43ms3096 KiB
15Partially correct2/44ms3380 KiB
16Partially correct2/44ms3280 KiB
17Partially correct2/47ms3364 KiB
18Partially correct2/410ms4020 KiB
19Partially correct2/410ms3888 KiB
20Partially correct2/410ms4140 KiB
21Partially correct2/412ms4096 KiB
22Wrong answer0/410ms4100 KiB