14882022-11-18 17:40:571478Fasor (40)cpp11Wrong answer 34/4074ms6076 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);
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base34/40
1Accepted0/03ms1812 KiB
2Accepted0/04ms2044 KiB
3Accepted2/22ms2208 KiB
4Wrong answer0/22ms2444 KiB
5Accepted2/22ms2612 KiB
6Accepted2/22ms2696 KiB
7Accepted2/22ms2804 KiB
8Accepted2/23ms2824 KiB
9Accepted2/24ms3060 KiB
10Accepted2/26ms3144 KiB
11Accepted2/26ms3268 KiB
12Accepted2/24ms3236 KiB
13Accepted2/237ms4028 KiB
14Wrong answer0/235ms4424 KiB
15Accepted2/257ms5144 KiB
16Accepted2/268ms5276 KiB
17Accepted2/274ms5744 KiB
18Accepted2/274ms5352 KiB
19Accepted2/274ms5124 KiB
20Wrong answer0/223ms4792 KiB
21Accepted2/259ms6076 KiB
22Accepted2/274ms5168 KiB