114402024-09-25 10:50:02tKriszFasor (40)cpp14Time limit exceeded 22/40298ms2792 KiB
#include <iostream>


using namespace std;


int main()
{
    int v[200002]={0};
    bool v1[200002]={0};
    int n,k;
    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){
            for(int j=i-1; j>=max(1,i-k);j--){
                if(v[i]>=v[j]){
                    if(v[i]>v[j]){
                        v1[j]=1;
                    }
                }
                else {
                    v1[i]=1;
                    break;
                }
            }
        }
        if(v1[i]==0){
            for(int j=i+1; j<=min(n,i+k);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/04ms1444 KiB
2Accepted0/07ms1452 KiB
3Accepted2/24ms1384 KiB
4Accepted2/24ms1552 KiB
5Accepted2/23ms1384 KiB
6Accepted2/23ms1656 KiB
7Accepted2/24ms1396 KiB
8Accepted2/24ms1388 KiB
9Accepted2/26ms1384 KiB
10Accepted2/27ms1440 KiB
11Accepted2/27ms1384 KiB
12Accepted2/26ms1424 KiB
13Time limit exceeded0/2298ms1948 KiB
14Time limit exceeded0/2298ms1868 KiB
15Time limit exceeded0/2296ms2328 KiB
16Time limit exceeded0/2296ms2344 KiB
17Time limit exceeded0/2296ms2664 KiB
18Time limit exceeded0/2296ms2540 KiB
19Time limit exceeded0/2294ms2664 KiB
20Time limit exceeded0/2296ms1640 KiB
21Time limit exceeded0/2296ms2280 KiB
22Accepted2/275ms2792 KiB