82532024-01-13 20:39:31szilHőségriadó (50 pont)cpp17Accepted 50/5010ms4612 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int MAXN = 200'001;

int a[MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k, l, f; cin >> n >> k >> l >> f;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int up = 0, down = 0; bool x = false;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] > f) up++;
        else up = 0;
        if (a[i] < f) down++;
        else down = 0;
        if (!x && up >= k) {
            ans++;
            x = true;
        }
        if (x && down >= l) {
            x = false;
        }
    }
    cout << ans << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1908 KiB
2Accepted0/010ms3016 KiB
3Accepted2/23ms2300 KiB
4Accepted2/23ms2512 KiB
5Accepted2/23ms2728 KiB
6Accepted2/23ms2940 KiB
7Accepted2/23ms3152 KiB
8Accepted4/43ms3396 KiB
9Accepted4/46ms3632 KiB
10Accepted4/47ms3668 KiB
11Accepted4/48ms3924 KiB
12Accepted4/47ms4132 KiB
13Accepted4/49ms4232 KiB
14Accepted4/43ms3692 KiB
15Accepted4/410ms4404 KiB
16Accepted4/410ms4532 KiB
17Accepted4/410ms4612 KiB