82722024-01-14 08:16:18MagyarKendeSZLGHőségriadó (50 pont)cpp17Wrong answer 0/5050ms5744 KiB
#include <bits/stdc++.h>
#define speed cin.tie(0); ios::sync_with_stdio(0)
using namespace std;

int N;

vector<int> ranges(const vector<int>& tempS, int K, bool mn) {
    vector<int> v(N - K + 1);
    deque<int> q;

    for (int i = 0; i < N; i++) {
        while (!q.empty() && i - q.front() >= K) q.pop_front();
        while (!q.empty() && (
            mn ? tempS[q.back()] >= tempS[i] : 
            tempS[q.back()] <= tempS[i]
        )) q.pop_back();
        
        q.push_back(i);

        if (i >= K - 1) {
            v[i - K + 1] = tempS[q.front()];
        }
    }
    
    return v;
}

int main() {
    int K, L, F;
    cin >> N >> K >> L >> F;

    vector<int> tempS(N);
    for (int& x : tempS) cin >> x;

    if (N < K || N < L) {
        cout << 0;
        exit(0);
    }

    vector<int> maxS = ranges(tempS, L, 0), minS = ranges(tempS, K, 1);

    for (int x : maxS) cout << x <<' '; 
    cout <<'\n';
    for (int x : minS) cout << x <<' '; 
    cout <<'\n';

    int result = 0;

    bool alert = 0;
    for (int i = 0; i < N - K - L; i++) {
        if (!alert && minS[i] > F) {
            alert = 1;
            result++;
        }
        else if (maxS[i] < F) {
            alert = 0;
        }
    }

    cout << result;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms1808 KiB
2Wrong answer0/050ms4452 KiB
3Wrong answer0/23ms2420 KiB
4Wrong answer0/23ms2564 KiB
5Wrong answer0/23ms2820 KiB
6Wrong answer0/23ms2872 KiB
7Wrong answer0/23ms3052 KiB
8Wrong answer0/43ms3156 KiB
9Wrong answer0/420ms4096 KiB
10Wrong answer0/426ms4224 KiB
11Wrong answer0/430ms4828 KiB
12Wrong answer0/426ms4436 KiB
13Wrong answer0/439ms5300 KiB
14Wrong answer0/46ms3640 KiB
15Wrong answer0/446ms5432 KiB
16Wrong answer0/446ms5428 KiB
17Wrong answer0/446ms5744 KiB