14902022-11-18 19:16:311478Fasor (40)cpp11Accepted 40/4075ms6696 KiB
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

int main()
{
    //ifstream cin("be.txt");
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }

    deque<int> dq;
    bool ans = 0;
    for (int i = 1; i <= n && !ans; i++)
    {
        if (!dq.empty() && i - dq.front() > k)
        {
            cout << dq.front() << " ";
            ans = 1;
        }
        while (!dq.empty() && a[i] > a[dq.back()])
        {
            dq.pop_back();
        }
        dq.push_back(i);
    }

    if (!ans)
    {
        if (!dq.empty())
            cout << dq.front();
        else
            cout << -1;
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted0/04ms2228 KiB
3Accepted2/22ms2256 KiB
4Accepted2/22ms2416 KiB
5Accepted2/22ms2616 KiB
6Accepted2/22ms2716 KiB
7Accepted2/22ms2928 KiB
8Accepted2/23ms3136 KiB
9Accepted2/24ms3512 KiB
10Accepted2/26ms3456 KiB
11Accepted2/26ms3452 KiB
12Accepted2/24ms3456 KiB
13Accepted2/237ms4244 KiB
14Accepted2/235ms4880 KiB
15Accepted2/259ms5604 KiB
16Accepted2/268ms5740 KiB
17Accepted2/275ms5940 KiB
18Accepted2/275ms5760 KiB
19Accepted2/274ms5848 KiB
20Accepted2/223ms5324 KiB
21Accepted2/259ms6696 KiB
22Accepted2/274ms5784 KiB