135922025-01-08 10:41:52tamasmarkHőségriadó (50 pont)cpp17Elfogadva 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
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/01ms496 KiB
2Elfogadva0/023ms564 KiB
3Elfogadva2/21ms316 KiB
4Elfogadva2/21ms316 KiB
5Elfogadva2/21ms316 KiB
6Elfogadva2/21ms316 KiB
7Elfogadva2/21ms316 KiB
8Elfogadva4/41ms404 KiB
9Elfogadva4/49ms572 KiB
10Elfogadva4/412ms748 KiB
11Elfogadva4/414ms564 KiB
12Elfogadva4/412ms612 KiB
13Elfogadva4/418ms724 KiB
14Elfogadva4/43ms316 KiB
15Elfogadva4/421ms760 KiB
16Elfogadva4/421ms564 KiB
17Elfogadva4/421ms564 KiB