85212024-01-20 11:39:56TomaSajtHőségriadó (50 pont)cpp17Accepted 50/5024ms3324 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, k, l, f;
  cin >> n >> k >> l >> f;

  bool alert = 0;
  int high_streak = 0, low_streak = 0;
  int res = 0;
  while (n--) {
    int a;
    cin >> a;
    if (a > f) {
      low_streak = 0;
      high_streak++;
    }
    else if (a < f) {
      low_streak++;
      high_streak = 0;
    }
    else {
      low_streak = 0;
      high_streak = 0;
    }
    if (high_streak >= k) {
      if (!alert) res++;
      alert = 1;
    }
    if (low_streak >= l) alert = 0;
  }
  cout << res;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1876 KiB
2Accepted0/024ms2120 KiB
3Accepted2/23ms2336 KiB
4Accepted2/23ms2516 KiB
5Accepted2/23ms2644 KiB
6Accepted2/23ms2728 KiB
7Accepted2/23ms2816 KiB
8Accepted4/43ms2964 KiB
9Accepted4/410ms2984 KiB
10Accepted4/413ms3108 KiB
11Accepted4/416ms3136 KiB
12Accepted4/413ms3104 KiB
13Accepted4/419ms3000 KiB
14Accepted4/44ms3004 KiB
15Accepted4/423ms3236 KiB
16Accepted4/423ms3324 KiB
17Accepted4/423ms3208 KiB