Solution to the problem number CODILITY_B-T3CHFEST_2019 of Codility - CODILITY_B-T3CHFEST_2019.

Any questions do not hesitate to contact.

#include <bits/stdc++.h>
using namespace std;

int solution(vector<int> &H)
{
    int res = 0;
    stack<int> sol;
    for (unsigned int i=0; i<H.size();i++)
    {
        while(!sol.empty() && sol.top() > H[i])
        {
            sol.pop();
        }
        if(!sol.empty() && sol.top() == H[i])
        {
            continue;
        }
        sol.push(H[i]);
        res+=1;
    }
    return res;
}
int main()
{
    for(int i=0; i<20;i++)
    {
        vector<int> V = {i,i+1,i+2,i+3,i+4,i+5,i+6,i+7,i+8};
        printf("%d\n",solution(V));
    }
    return 0;
}

Don't miss anything.

Keep in touch with Isaac Lozano Osorio!