114422024-09-25 10:57:02tKriszFasor (40)cpp14Time limit exceeded 20/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++)
    {
            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;
                }
            }

            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;
                }
            }
        if(v1[i]==0){
            cout<<i;
            break;
        }
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base20/40
1Accepted0/03ms1384 KiB
2Accepted0/06ms1400 KiB
3Accepted2/23ms1400 KiB
4Accepted2/23ms1324 KiB
5Accepted2/23ms1400 KiB
6Accepted2/23ms1384 KiB
7Accepted2/23ms1400 KiB
8Accepted2/24ms1272 KiB
9Accepted2/26ms1388 KiB
10Accepted2/27ms1392 KiB
11Accepted2/27ms1416 KiB
12Accepted2/24ms1272 KiB
13Time limit exceeded0/2296ms1384 KiB
14Time limit exceeded0/2289ms1396 KiB
15Time limit exceeded0/2293ms1384 KiB
16Time limit exceeded0/2291ms1400 KiB
17Time limit exceeded0/2294ms1384 KiB
18Time limit exceeded0/2298ms1128 KiB
19Time limit exceeded0/2298ms1384 KiB
20Time limit exceeded0/2294ms1384 KiB
21Time limit exceeded0/2296ms1128 KiB
22Time limit exceeded0/2294ms1528 KiB