82372024-01-13 18:48:36rennHőségriadó (50 pont)cpp17Accepted 50/5010ms4000 KiB
#include <bits/stdc++.h>

using namespace std;

int main() {

    cin.tie(0);
    ios::sync_with_stdio(0);

    int n, riadnap, lemondnap, f;
    cin >> n >> riadnap >> lemondnap >> f;

    int riadok = 0;

    int curr;
    bool vesz = false;

    int sorlenr = 0, sorlenl = 0;
    vector<bool> valtasok;

    while(n--)
    {
        cin >> curr;
        if(curr == f)
        {
            sorlenr = sorlenl = 0;
            continue;
        }
        vesz = curr > f;
        //cout << vesz << " ";

        if(vesz)
        {
            sorlenr++;
            sorlenl = 0;

            if(sorlenr == riadnap)
            {
                valtasok.push_back(1);
            }
        }
        else
        {
            sorlenl++;
            sorlenr = 0;

            if(sorlenl == lemondnap)
            {
                valtasok.push_back(0);
            }
        }
    }

    vesz = false;
    for(bool x : valtasok)
    {
        //cout << x << " " << vesz << "\n";
        if(x && !vesz)
            riadok++;
        vesz = x;
    }
    //cout << "\n";

    cout << riadok << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1824 KiB
2Accepted0/010ms2024 KiB
3Accepted2/23ms2368 KiB
4Accepted2/23ms2584 KiB
5Accepted2/23ms2668 KiB
6Accepted2/23ms2880 KiB
7Accepted2/23ms2976 KiB
8Accepted4/43ms3112 KiB
9Accepted4/46ms3308 KiB
10Accepted4/47ms3412 KiB
11Accepted4/48ms3492 KiB
12Accepted4/47ms3636 KiB
13Accepted4/49ms3636 KiB
14Accepted4/43ms3608 KiB
15Accepted4/49ms3732 KiB
16Accepted4/49ms3904 KiB
17Accepted4/49ms4000 KiB