82762024-01-14 08:30:05MagyarKendeSZLGHőségriadó (50 pont)cpp17Accepted 50/5024ms4960 KiB
#include <bits/stdc++.h>
#define speed cin.tie(0); ios::sync_with_stdio(0)
using namespace std;

vector<int> v;

bool rsml(int i, int j, int F) {
    for (; i <= j; i++) {
        if (v[i] >= F) return 0;
    }
    return 1;
}

bool rbg(int i, int j, int F) {
    for (; i <= j; i++) {
        if (v[i] <= F) return 0;
    }
    return 1;
}

int main() {
    int N, K, L, F;
    cin >> N >> K >> L >> F;

    v.resize(N);
    for (int& x : v) cin >> x;

    int result = 0;
    bool alert = 0;
    for (int i = K - 1; i < N; i++) {
        if (!alert && rbg(i - K + 1, i, F)) {
            alert = 1;
            result++;
        }
        else if (0 <= i - L + 1 && alert && rsml(i - L + 1, i, F)) {
            alert = 0;
        }
    }

    cout << result;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1876 KiB
2Accepted0/024ms2824 KiB
3Accepted2/23ms2332 KiB
4Accepted2/23ms2548 KiB
5Accepted2/23ms2756 KiB
6Accepted2/23ms3004 KiB
7Accepted2/23ms3216 KiB
8Accepted4/43ms3308 KiB
9Accepted4/410ms3732 KiB
10Accepted4/414ms4092 KiB
11Accepted4/416ms3996 KiB
12Accepted4/413ms4156 KiB
13Accepted4/419ms4356 KiB
14Accepted4/44ms4060 KiB
15Accepted4/421ms4952 KiB
16Accepted4/421ms4960 KiB
17Accepted4/421ms4956 KiB