214812026-01-13 10:20:59gkataHőségriadó (50 pont)cpp17Accepted 50/5023ms508 KiB


// hosegriado.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#define ll long long

using namespace std;

bool ok = false;
ll k, l, f, n, i, a, db1, db2, db;

int main()
{
    cin >> n >> k >> l >> f;

    for (i = 1; i <= n; ++i)
    {
        cin >> a;
        
        if (a > f)
        {
            ++db1;
            db2 = 0;
        }

        else if (a < f)
        {
            ++db2;
            db1 = 0;
        }

        else
        {
            db1 = 0;
            db2 = 0;
        }

        if (db1 >= k && ok == false)
        {
            ++db;
            ok = true;
        }

        else if (db2 >= l && ok == true) ok = false;
    }

    cout << db;

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms316 KiB
2Accepted0/023ms316 KiB
3Accepted2/22ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms332 KiB
8Accepted4/41ms316 KiB
9Accepted4/49ms404 KiB
10Accepted4/412ms352 KiB
11Accepted4/414ms508 KiB
12Accepted4/412ms396 KiB
13Accepted4/418ms500 KiB
14Accepted4/42ms316 KiB
15Accepted4/420ms392 KiB
16Accepted4/421ms400 KiB
17Accepted4/420ms396 KiB