76312024-01-10 09:48:32BenedekMartonSíkság (55)cpp17Wrong answer 0/5535ms5644 KiB
#include <iostream>

using namespace std;

int main()
{
    int n, k, r;
    cin >> n >> k;
    int t[n];
    for(int i=0; i<n; i++)
    {
        cin >> t[i];
    }
    int bgi, latmax=0, latmaxi=-1;
    for(int i=0; i<min(k, n); i++)
    {
        if(latmax<=t[i])
        {
            latmax=t[i];
            latmaxi=i;
        }
    }
    for(int i=0; i<n; i++)
    {
        r=min(i+k, n-1);
        if(latmax<=t[r]) // megoldani a tullepest
        {
            latmax=t[r];
            latmaxi=r;
        }
        if(latmax==t[i])
        {
            cout << i+1;
            return 0;
        }
        else if(latmaxi<i-k)
        {
            latmax=0;
            for(int j=i-k; j<=r; j++)
            {
                if(latmax<=t[j])
                {
                    latmax=t[j];
                    latmaxi=j;
                }
            }
        }
    }
    cout << -1;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/03ms1876 KiB
2Wrong answer0/04ms2232 KiB
3Wrong answer0/23ms2324 KiB
4Wrong answer0/23ms2360 KiB
5Wrong answer0/23ms2516 KiB
6Wrong answer0/23ms2648 KiB
7Wrong answer0/33ms2736 KiB
8Wrong answer0/23ms3032 KiB
9Wrong answer0/33ms3104 KiB
10Wrong answer0/36ms3244 KiB
11Wrong answer0/34ms3548 KiB
12Wrong answer0/34ms3788 KiB
13Wrong answer0/332ms4644 KiB
14Wrong answer0/319ms4880 KiB
15Wrong answer0/327ms4912 KiB
16Wrong answer0/335ms5380 KiB
17Wrong answer0/335ms5276 KiB
18Wrong answer0/335ms5496 KiB
19Wrong answer0/335ms5620 KiB
20Wrong answer0/335ms5644 KiB
21Wrong answer0/318ms5268 KiB
22Wrong answer0/328ms5508 KiB