135922025-01-08 10:41:52tamasmarkHőségriadó (50 pont)cpp17Accepted 50/5023ms760 KiB
// hosegriado.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>

using namespace std;

int i, j, n, k,l,atlag;
bool hosegriado;
vector<int>x;
int a, b;
int main()
{
    cin >> n >> k >> l >> atlag;
    x.resize(n + 1);
    for (i = 1; i <= n; ++i)
        cin >> x[i];

    for (i = 1; i <= n; ++i)
    {
        if (x[i] > atlag && hosegriado == false) a++;
        if (x[i] < atlag && hosegriado == true) b++;
        if (x[i] >= atlag) b = 0;
        if (x[i] <= atlag) a = 0;
        if (x[i] > atlag && a >= k)
        {

            hosegriado = true;
            j++;
            a = 0;
            b = 0;
        }
        if (x[i] < atlag && b >= l)
        {
            hosegriado = false;
            a = 0;
            b = 0;
        }
    }
    cout << j;
    return 0;
}
/*
9 2 2 30
28 32 32 28 32 26 26 32 32
*/
// 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/01ms496 KiB
2Accepted0/023ms564 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted4/41ms404 KiB
9Accepted4/49ms572 KiB
10Accepted4/412ms748 KiB
11Accepted4/414ms564 KiB
12Accepted4/412ms612 KiB
13Accepted4/418ms724 KiB
14Accepted4/43ms316 KiB
15Accepted4/421ms760 KiB
16Accepted4/421ms564 KiB
17Accepted4/421ms564 KiB