Submission #1327135

#TimeUsernameProblemLanguageResultExecution timeMemory
1327135SSKMFRabbit Carrot (LMIO19_triusis)C++20
0 / 100
1 ms332 KiB
#include <bits/stdc++.h>
using namespace std;

int64_t stiva[200002];

int main ()
{
    ios :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int lungime , limita;
    cin >> lungime >> limita;
    
    stiva[0] = 1;
    for (int indice = 1 ; indice <= lungime ; indice++)
    {
        int64_t valoare;
        cin >> valoare;

        valoare -= 1LL * indice * limita;
        if (stiva[stiva[0]] >= valoare)
            { stiva[++stiva[0]] = valoare; continue; }

        int stanga = 1 , dreapta = stiva[0];
        while (stanga <= dreapta)
        {
            const int mijloc = (stanga + dreapta) >> 1;
            if (stiva[mijloc] >= valoare) { stanga = mijloc + 1; }
            else { dreapta = mijloc - 1; }
        }

        stiva[stanga] = valoare;
    }

    cout << lungime + 1 - stiva[0];
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...