86142024-01-23 16:37:13Wrinkle1564Hőségriadó (50 pont)cpp17Accepted 50/5024ms4176 KiB
#include <iostream>

using std::cin;
using std::cout;

auto main() -> int {
    // osszesen ennyi nap van
    int n = 0;
    // egymas utani mikor elrendelik
    int k = 0;
    // egymas utani mikor lefujjak
    int l = 0;
    // a homerseklet, mely felett hosegriado lehet
    int f = 0;
    cin >> n >> k >> l >> f;

    // osszesen ennyiszer rendelnek el hosegriadot
    int sum = 0;
    // aktualis hom
    int current = 0;
    // egymas utani meleg napok
    int cons_hot = 0;
    // egymas utani hideg napok
    int cons_cold = 0;
    // hosegriado van
    bool warn_hot = false;

    for (int _ = 0; _ < n; _++) {
        cin >> current;
        // meleg
        if (current > f && !warn_hot) {
            // cout << current << " meleg\n";
            cons_hot++;
        } else {
            cons_hot = 0;
        }
        if (cons_hot == k && !warn_hot) {
            warn_hot = true;
            sum++;
        }

        // hideg
        if (current < f && warn_hot) {
            cons_cold++;
        } else {
            cons_cold = 0;
        }
        if (cons_cold == l && warn_hot) {
            // cout << "\nno hosegriado!\n";
            warn_hot = false;
        }
    }
    cout << sum;

    cout << std::endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1872 KiB
2Accepted0/024ms2068 KiB
3Accepted2/23ms2312 KiB
4Accepted2/23ms2524 KiB
5Accepted2/23ms2704 KiB
6Accepted2/23ms2816 KiB
7Accepted2/23ms3164 KiB
8Accepted4/43ms3100 KiB
9Accepted4/410ms3220 KiB
10Accepted4/414ms3340 KiB
11Accepted4/416ms3556 KiB
12Accepted4/413ms3612 KiB
13Accepted4/419ms3844 KiB
14Accepted4/44ms4096 KiB
15Accepted4/421ms4176 KiB
16Accepted4/423ms4144 KiB
17Accepted4/423ms4144 KiB