86202024-01-23 18:22:41Wrinkle1564Hőségriadó (50 pont)cpp11Accepted 50/5024ms3964 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++;
            if (cons_hot == k) {
                warn_hot = true;
                sum++;
            }
        } else {
            cons_hot = 0;
        }

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

    cout << std::endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1876 KiB
2Accepted0/024ms2068 KiB
3Accepted2/23ms2280 KiB
4Accepted2/23ms2428 KiB
5Accepted2/23ms2592 KiB
6Accepted2/23ms2804 KiB
7Accepted2/22ms2912 KiB
8Accepted4/43ms3272 KiB
9Accepted4/410ms3324 KiB
10Accepted4/414ms3704 KiB
11Accepted4/416ms3812 KiB
12Accepted4/413ms3592 KiB
13Accepted4/419ms3476 KiB
14Accepted4/44ms3604 KiB
15Accepted4/421ms3688 KiB
16Accepted4/423ms3800 KiB
17Accepted4/423ms3964 KiB