14902022-11-18 19:16:311478Fasor (40)cpp11Elfogadva 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;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/40
1Elfogadva0/03ms1812 KiB
2Elfogadva0/04ms2228 KiB
3Elfogadva2/22ms2256 KiB
4Elfogadva2/22ms2416 KiB
5Elfogadva2/22ms2616 KiB
6Elfogadva2/22ms2716 KiB
7Elfogadva2/22ms2928 KiB
8Elfogadva2/23ms3136 KiB
9Elfogadva2/24ms3512 KiB
10Elfogadva2/26ms3456 KiB
11Elfogadva2/26ms3452 KiB
12Elfogadva2/24ms3456 KiB
13Elfogadva2/237ms4244 KiB
14Elfogadva2/235ms4880 KiB
15Elfogadva2/259ms5604 KiB
16Elfogadva2/268ms5740 KiB
17Elfogadva2/275ms5940 KiB
18Elfogadva2/275ms5760 KiB
19Elfogadva2/274ms5848 KiB
20Elfogadva2/223ms5324 KiB
21Elfogadva2/259ms6696 KiB
22Elfogadva2/274ms5784 KiB