25772023-01-17 15:26:45NandikaaFasor (40)cpp11Accepted 40/4074ms5332 KiB
#include <iostream>

using namespace std;

int main()
{
    int n;
    int d;
    cin >> n;
    cin >> d;
    int fasor [n];
    for (int i = 0; i< n;i++){
        cin >> fasor[i];
    }
    bool rosszhely;
    for (int i = 0; i < n; i++){
        rosszhely=false;
        for (int j=i-d; j <= i+d;j++){
            if (j >= 0 && j<n){
            if (fasor[j] > fasor[i]){
                i=j-1;
                rosszhely = true;
                break;
                }
            }
        }
        if (rosszhely == false){
            cout << i+1;
            return 0;
        }
    }
    cout << "-1";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1748 KiB
2Accepted0/04ms2036 KiB
3Accepted2/22ms2076 KiB
4Accepted2/22ms2240 KiB
5Accepted2/22ms2440 KiB
6Accepted2/22ms2552 KiB
7Accepted2/22ms2664 KiB
8Accepted2/23ms2872 KiB
9Accepted2/24ms2976 KiB
10Accepted2/26ms3064 KiB
11Accepted2/26ms2980 KiB
12Accepted2/24ms3108 KiB
13Accepted2/237ms3924 KiB
14Accepted2/237ms3920 KiB
15Accepted2/257ms4808 KiB
16Accepted2/267ms4816 KiB
17Accepted2/272ms4932 KiB
18Accepted2/272ms5060 KiB
19Accepted2/274ms5152 KiB
20Accepted2/223ms4432 KiB
21Accepted2/259ms5228 KiB
22Accepted2/272ms5332 KiB