127562024-12-29 21:54:19xxxHőségriadó (50 pont)cpp17Accepted 50/5023ms1196 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
	int n, k, l, f;
	cin >> n >> k >> l >> f;
	vector<int> v(n+1);
	for(int i = 1; i <= n; i++) {
		cin >> v[i];
	}

	int kmost = 0;
	int lmost = 0;
	bool riado = 0;
	int ans = 0;

	for(int i = 1; i <= n; i++) {
		if (v[i] > f) {
			kmost++;
			lmost = 0;
		}
		if (v[i] < f) {
			lmost++;
			kmost = 0;
		}
		if (v[i] == f) {
			lmost = kmost = 0;
		}

		if(kmost == k) {
			kmost = 0;
			if (!riado) {
				riado = 1;
				ans++;
			}
		}
		if(lmost == l) {
			lmost = 0;
			riado = 0;
		}

	}
	cout << ans << endl;

}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms320 KiB
2Accepted0/023ms1196 KiB
3Accepted2/21ms320 KiB
4Accepted2/21ms320 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms320 KiB
7Accepted2/21ms320 KiB
8Accepted4/42ms320 KiB
9Accepted4/49ms732 KiB
10Accepted4/412ms808 KiB
11Accepted4/414ms884 KiB
12Accepted4/412ms748 KiB
13Accepted4/417ms824 KiB
14Accepted4/42ms320 KiB
15Accepted4/420ms1124 KiB
16Accepted4/420ms1120 KiB
17Accepted4/420ms1120 KiB