114412024-09-25 10:53:39tKriszFasor (40)cpp14Time limit exceeded 22/40298ms1528 KiB
#include <iostream>


using namespace std;


int main()
{
    int v[200002]={0};
    bool v1[200002]={0};
    int n,k, temp1;
    cin>>n>>k;
    v[0]=-1;
    v[n+1]=-1;
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(v1[i]==0){
            temp1=max(1,i-k);
            for(int j=i-1; j>=temp1;j--){
                if(v[i]>=v[j]){
                    if(v[i]>v[j]){
                        v1[j]=1;
                    }
                }
                else {
                    v1[i]=1;
                    break;
                }
            }
        }
        if(v1[i]==0){
            temp1=min(n,i+k);
            for(int j=i+1; j<=temp1;j++){
                if(v[i]>=v[j]){
                    if(v[i]>v[j]){
                        v1[j]=1;
                    }
                }
                else {
                    v1[i]=1;
                    break;
                }
            }
        }
        if(v1[i]==0){
            cout<<i;
            break;
        }
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base22/40
1Accepted0/03ms1384 KiB
2Accepted0/06ms1384 KiB
3Accepted2/23ms1384 KiB
4Accepted2/23ms1400 KiB
5Accepted2/23ms1404 KiB
6Accepted2/23ms1384 KiB
7Accepted2/23ms1400 KiB
8Accepted2/24ms1528 KiB
9Accepted2/26ms1400 KiB
10Accepted2/27ms1400 KiB
11Accepted2/27ms1528 KiB
12Accepted2/24ms1384 KiB
13Time limit exceeded0/2296ms1384 KiB
14Time limit exceeded0/2298ms1384 KiB
15Time limit exceeded0/2293ms1384 KiB
16Time limit exceeded0/2296ms1264 KiB
17Time limit exceeded0/2298ms1384 KiB
18Time limit exceeded0/2298ms1384 KiB
19Time limit exceeded0/2294ms1396 KiB
20Time limit exceeded0/2294ms1384 KiB
21Time limit exceeded0/2293ms1384 KiB
22Accepted2/275ms1512 KiB