70882023-12-30 11:01:411478Fasor (40)cpp17Wrong answer 16/40144ms21944 KiB
#include <bits/stdc++.h>  
 
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("in.txt");
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }

    set<pair<int, int>> s;
    for(int i = 1; i <= 2*k+1; i++){
        s.insert({a[i], i});
    }

    int i = k + 1;
    bool ansFound = false;
    while(i <= n && !ansFound){
        if(a[i] == s.crbegin() -> first){
            cout << i;
            ansFound = true;
        }
        else{
            s.erase({a[i - k], i - k});
            if(i + k + 1 <= n){
                s.insert({a[i + k + 1], i + k + 1});
            }
        }
        i++;
    }
}
SubtaskSumTestVerdictTimeMemory
base16/40
1Accepted0/03ms1816 KiB
2Accepted0/04ms2228 KiB
3Wrong answer0/23ms2220 KiB
4Accepted2/23ms2456 KiB
5Wrong answer0/23ms2792 KiB
6Accepted2/23ms2852 KiB
7Wrong answer0/23ms2892 KiB
8Accepted2/23ms2964 KiB
9Wrong answer0/26ms3216 KiB
10Accepted2/26ms3172 KiB
11Accepted2/26ms3156 KiB
12Wrong answer0/24ms3416 KiB
13Accepted2/264ms8964 KiB
14Runtime error0/257ms13848 KiB
15Wrong answer0/2128ms20384 KiB
16Wrong answer0/2136ms15932 KiB
17Wrong answer0/2144ms20772 KiB
18Accepted2/297ms11836 KiB
19Accepted2/293ms6980 KiB
20Wrong answer0/248ms13352 KiB
21Wrong answer0/2123ms21944 KiB
22Wrong answer0/2143ms13568 KiB