82642024-01-13 21:21:26bovizdbHőségriadó (50 pont)cpp17Accepted 50/5012ms4536 KiB
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define endl "\n"
#define pll pair<ll, ll>
#define fs first
#define sc second
#define vll vector<ll>
#define v2d vector<vector<ll>>
#define vpll vector<pll>
#define qll queue<ll>
#define stll stack<ll>
#define sll set<ll>
#define mll map<ll, ll>

ll n, k, l, f;
vll v;

void solve()
{
    cin >> n >> k >> l >> f;
    v.resize(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    ll klen = 0, llen = 0, out = 0;
    bool b = 0;
    for (ll i = 0; i < n; i++)
    {
        if (v[i] == f)
        {
            llen = 0;
            klen = 0;
            continue;
        }
        if (v[i] > f)
        {
            llen = 0;
            klen++;
        }
        else if (v[i] < f)
        {
            klen = 0;
            llen++;
        }
        if (b == 1 && llen >= l)
        {
            b = 0;
        }
        if (b == 0 && klen >= k)
        {
            b = 1;
            out++;
        }
    }
    cout << out;
}
 
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1892 KiB
2Accepted0/012ms3584 KiB
3Accepted2/23ms2332 KiB
4Accepted2/23ms2544 KiB
5Accepted2/23ms2772 KiB
6Accepted2/23ms2948 KiB
7Accepted2/23ms2924 KiB
8Accepted4/43ms3024 KiB
9Accepted4/46ms3308 KiB
10Accepted4/47ms3704 KiB
11Accepted4/48ms3960 KiB
12Accepted4/47ms3912 KiB
13Accepted4/49ms4436 KiB
14Accepted4/43ms3388 KiB
15Accepted4/410ms4532 KiB
16Accepted4/410ms4532 KiB
17Accepted4/410ms4536 KiB