84212024-01-15 19:59:29kukkermanHőségriadó (50 pont)cpp17Accepted 50/5024ms4788 KiB
#include <iostream>
#include <vector>

void beolvas(std::istream &be, int &k, int &l, int &f, std::vector<int> &homersekletek) {
    int n;
    be >> n >> k >> l >> f;

    homersekletek.resize(n);
    for (auto &h : homersekletek) {
        be >> h;
    }
}

void feldolgoz(int k, int l, int f, const std::vector<int> &homersekletek) {
    int alatt_db = 0, folott_db = 0, riado_db = 0;
    bool riado = false;

    for (auto h : homersekletek) {
        if (h > f) {
            folott_db++;
            alatt_db = 0;
            if (folott_db == k && !riado) {
                riado = true;
                riado_db++;
            }

        } else if (h < f) {
            alatt_db++;
            folott_db = 0;
            if (alatt_db == l && riado) {
                riado = false;
            }

        } else {
            alatt_db = 0;
            folott_db = 0;
        }
    }

    std::cout << riado_db << '\n';
}

int main() {
    int k, l, f;
    std::vector<int> homersekletek;
    beolvas(std::cin, k, l, f, homersekletek);

    feldolgoz(k, l, f, homersekletek);

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1680 KiB
2Accepted0/024ms2556 KiB
3Accepted2/23ms2072 KiB
4Accepted2/23ms2304 KiB
5Accepted2/23ms2484 KiB
6Accepted2/23ms2696 KiB
7Accepted2/23ms2940 KiB
8Accepted4/43ms3156 KiB
9Accepted4/412ms3824 KiB
10Accepted4/414ms3932 KiB
11Accepted4/416ms4204 KiB
12Accepted4/413ms4232 KiB
13Accepted4/419ms4208 KiB
14Accepted4/44ms4252 KiB
15Accepted4/423ms4768 KiB
16Accepted4/423ms4672 KiB
17Accepted4/423ms4788 KiB