84762024-01-17 11:45:36GervidHőségriadó (50 pont)cpp17Accepted 50/5024ms3548 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n, k, l, f, i, out = 0;
	cin >> n >> k >> l >> f;

	vector<short> days(n);

	for (i = 0; i < n; i++)
	{
		cin >> days[i];
	}

	int abovefor = 0, belowfor = 0, isalarm = false;

	for (i = 0; i < n; i++)
	{
		if (days[i] > f)
		{
			belowfor = 0;
			abovefor++;

			if (abovefor == k && !isalarm)
			{
				out++;
				isalarm = true;
			}
		}
		else
		{
			if (days[i] < f)
			{
				abovefor = 0;
				belowfor++;

				if (belowfor == l)
				{
					isalarm = false;
				}
			}
			else //egyenlõk
			{
				belowfor = 0;
				abovefor = 0;
			}
		}
	}

	cout << out;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1812 KiB
2Accepted0/024ms2316 KiB
3Accepted2/23ms2212 KiB
4Accepted2/23ms2428 KiB
5Accepted2/22ms2508 KiB
6Accepted2/23ms2636 KiB
7Accepted2/23ms2724 KiB
8Accepted4/43ms2972 KiB
9Accepted4/410ms3288 KiB
10Accepted4/413ms3104 KiB
11Accepted4/416ms3120 KiB
12Accepted4/413ms3100 KiB
13Accepted4/419ms3220 KiB
14Accepted4/44ms3052 KiB
15Accepted4/423ms3296 KiB
16Accepted4/421ms3296 KiB
17Accepted4/423ms3548 KiB