28012023-01-26 08:30:31gkataFasor (40)cpp17Runtime error 38/4075ms8608 KiB
#include <iostream>
//#include <fstream>
#include <vector>
#include <climits>
#define ll long long

using namespace std;

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

vector <ll>x;

ll n,k,i,j,a,maxi=LONG_MIN,maxi2=LONG_MIN,pos,pos2;

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

    for(i=0;i<=k;++i)
        if(x[i]>maxi)
        {
            maxi=x[i];
            pos=i;
        }
    for(i=(pos+1);i<=(pos+k);++i)
        if(x[i]>maxi2)
        {
            maxi2=x[i];
            pos2=i;
        }
    if(maxi>=maxi2) cout<<pos+1;
        else
        {
            while(maxi<maxi2)
            {
                pos=pos2;
                maxi=maxi2;
                for(i=(pos+1);i<=(pos+k);++i)
                if(x[i]>maxi2)
                {
                    maxi2=x[i];
                    pos2=i;
                }
            }
            cout<<pos+1;
        }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base38/40
1Accepted0/03ms1872 KiB
2Accepted0/04ms2504 KiB
3Accepted2/22ms2292 KiB
4Accepted2/22ms2524 KiB
5Accepted2/22ms2728 KiB
6Accepted2/22ms2936 KiB
7Accepted2/22ms3152 KiB
8Accepted2/23ms3244 KiB
9Accepted2/24ms3916 KiB
10Accepted2/26ms3968 KiB
11Accepted2/26ms3924 KiB
12Accepted2/24ms3900 KiB
13Accepted2/239ms5632 KiB
14Runtime error0/235ms5636 KiB
15Accepted2/259ms7932 KiB
16Accepted2/270ms7972 KiB
17Accepted2/275ms8172 KiB
18Accepted2/275ms8140 KiB
19Accepted2/275ms8132 KiB
20Accepted2/224ms6136 KiB
21Accepted2/261ms8200 KiB
22Accepted2/275ms8608 KiB