82602024-01-13 21:06:59bovizdbHőségriadó (50 pont)cpp17Wrong answer 18/5012ms4548 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)
        {
            klen = 0;
        }
        if (b == 1 && llen >= l)
        {
            b = 0;
        }
        if (klen >= k && b == 0)
        {
            b = 1;
            out++;
        }
        if (v[i] > f)
        {
            llen = 0;
            klen++;
        }
        else if (v[i] < f)
        {
            klen = 0;
            llen++;
        }
    }
    if (klen >= k && b == 0)
    {
        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
base18/50
1Accepted0/03ms1888 KiB
2Accepted0/012ms3552 KiB
3Accepted2/23ms2168 KiB
4Accepted2/23ms2296 KiB
5Accepted2/23ms2420 KiB
6Accepted2/23ms2608 KiB
7Accepted2/23ms2836 KiB
8Wrong answer0/43ms3064 KiB
9Wrong answer0/46ms3416 KiB
10Accepted4/47ms4048 KiB
11Accepted4/48ms4124 KiB
12Wrong answer0/47ms4008 KiB
13Wrong answer0/49ms4528 KiB
14Wrong answer0/43ms3376 KiB
15Wrong answer0/410ms4528 KiB
16Wrong answer0/410ms4532 KiB
17Wrong answer0/410ms4548 KiB