123772024-12-14 13:07:34helloworldFasor (40)cpp17Wrong answer 0/401ms508 KiB
#include <iostream>
#include <fstream>
#include <deque>
#include <vector>
using namespace std;

int main() {
    ifstream input("input.txt");
    ofstream output("output.txt");

    int N, K;
    input >> N >> K;

    vector<int> heights(N);
    for (int i = 0; i < N; i++) {
        input >> heights[i];
    }

    deque<int> dq;
    for (int i = 0; i < N; i++) {
        while (!dq.empty() && dq.front() < i - K) {
            dq.pop_front();
        }

        while (!dq.empty() && heights[dq.back()] <= heights[i]) {
            dq.pop_back();
        }

        dq.push_back(i);

        if (heights[dq.front()] <= heights[i]) {
            output << i + 1 << endl;
            return 0;
        }
    }

    output << -1 << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/01ms320 KiB
2Wrong answer0/01ms320 KiB
3Wrong answer0/21ms508 KiB
4Wrong answer0/21ms500 KiB
5Wrong answer0/21ms320 KiB
6Wrong answer0/21ms500 KiB
7Wrong answer0/21ms320 KiB
8Wrong answer0/21ms332 KiB
9Wrong answer0/21ms388 KiB
10Wrong answer0/21ms320 KiB
11Wrong answer0/21ms320 KiB
12Wrong answer0/21ms320 KiB
13Wrong answer0/21ms320 KiB
14Wrong answer0/21ms320 KiB
15Wrong answer0/21ms360 KiB
16Wrong answer0/21ms388 KiB
17Wrong answer0/21ms320 KiB
18Wrong answer0/21ms320 KiB
19Wrong answer0/21ms320 KiB
20Wrong answer0/21ms320 KiB
21Wrong answer0/21ms324 KiB
22Wrong answer0/21ms508 KiB