20302022-12-15 12:04:19gkataFasor (40)cpp17Time limit exceeded 22/40300ms6516 KiB
#include <iostream>
//#include <fstream>
#include <vector>

using namespace std;

//ifstream cin("fasor.in");
//ofstream cout("fasor.out");

vector <int>x;

int n,k,i,j,a,b,db1,db2,l;

int main()
{
    cin>>n>>k;
    for(i=1;i<=n;++i)
    {
        cin>>a;
        x.push_back(a);
    }

    for(i=0;i<n;++i)
    {
        db1=0;
        for(j=i+1;j<=(i+k);++j)
        {
            if(x[j]>x[i]) ++db1;
            if(db1>0)
                break;
        }

    if(db1==0)
    {

            db2=0;
            if((i-k)<0) b=0;
            else b=i-k;

            for(l=b;l<i;++l)
            {
                if(x[l]>x[i]) ++db2;
                if(db2>0)
                    break;
            }
    }
    if(db1==0 && db2==0)
    {
        cout<<i+1;
        break;
    }
    }
    if(db2>0) cout<<-1;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base22/40
1Accepted0/03ms1876 KiB
2Accepted0/04ms2348 KiB
3Accepted2/22ms2396 KiB
4Accepted2/22ms2600 KiB
5Accepted2/22ms2796 KiB
6Accepted2/22ms3004 KiB
7Accepted2/22ms3088 KiB
8Accepted2/23ms3324 KiB
9Accepted2/24ms3388 KiB
10Accepted2/24ms3392 KiB
11Accepted2/26ms3664 KiB
12Accepted2/24ms3520 KiB
13Time limit exceeded0/2300ms3224 KiB
14Time limit exceeded0/2252ms3384 KiB
15Time limit exceeded0/2261ms3828 KiB
16Time limit exceeded0/2261ms3824 KiB
17Time limit exceeded0/2264ms4032 KiB
18Time limit exceeded0/2280ms4036 KiB
19Time limit exceeded0/2246ms4240 KiB
20Time limit exceeded0/2280ms3924 KiB
21Time limit exceeded0/2248ms4656 KiB
22Accepted2/271ms6516 KiB