14882022-11-18 17:40:571478Fasor (40)cpp11Hibás válasz 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;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base34/40
1Elfogadva0/03ms1812 KiB
2Elfogadva0/04ms2044 KiB
3Elfogadva2/22ms2208 KiB
4Hibás válasz0/22ms2444 KiB
5Elfogadva2/22ms2612 KiB
6Elfogadva2/22ms2696 KiB
7Elfogadva2/22ms2804 KiB
8Elfogadva2/23ms2824 KiB
9Elfogadva2/24ms3060 KiB
10Elfogadva2/26ms3144 KiB
11Elfogadva2/26ms3268 KiB
12Elfogadva2/24ms3236 KiB
13Elfogadva2/237ms4028 KiB
14Hibás válasz0/235ms4424 KiB
15Elfogadva2/257ms5144 KiB
16Elfogadva2/268ms5276 KiB
17Elfogadva2/274ms5744 KiB
18Elfogadva2/274ms5352 KiB
19Elfogadva2/274ms5124 KiB
20Hibás válasz0/223ms4792 KiB
21Elfogadva2/259ms6076 KiB
22Elfogadva2/274ms5168 KiB