Cod sursa(job #2659121)

Utilizator Razvan48Capatina Razvan Nicolae Razvan48 Data 15 octombrie 2020 21:08:22
Problema Secventa Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <fstream>
#include <climits>

using namespace std;

int main()
{
    ifstream in("secventa.in");
    ofstream out("secventa.out");
    int n, k, x;

    int stMax, drMax, lMax, lcrt = 0;
    int bCrt = INT_MAX, bMin;
    int i;

    in >> n >> k;
    for (i = 1; i <= n; i++)
    {
        in >> x;
        if (x < k)
        {
            if (lcrt > lMax)
            {
                stMax = i - lcrt;
                drMax = i - 1;
                lMax = lcrt;
                bMin = bCrt;
            }
            lcrt = 0;
            bCrt = INT_MAX;
        }
        else
        {
            lcrt++;
            if (x < bCrt)
            {
                bCrt = x;
            }
        }
    }
    if (lcrt > lMax)
    {
        stMax = i - lcrt;
        drMax = i - 1;
        lMax = lcrt;
        bMin = bCrt;
    }

    out << stMax << ' ' << drMax << ' ' << bMin << '\n';

    return 0;
}