65142023-12-05 18:38:53antiFasor (40)cpp14Accepted 40/4074ms8988 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, d;
    cin >> n >> d;
    vector<int> F;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        F.push_back(a);
    }
    for (int i = 0; i < d; i++) {
        F.push_back(0);
    }

    int maxi = 0, max = F[0], megoldas = -1, h=0, maxih = 0;
    bool kesz = false;
    do {
        maxih = maxi;
        for (int i = maxih+1; i <= maxih + d; i++) {
            if (F[i] > max) {
                max = F[i];
                maxi = i;
                h++;
            }
        }
        if (h == 0) {
            megoldas = maxi + 1;
            kesz = true;
        }
        h = 0;
    } while (!kesz);
    cout << megoldas;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted0/04ms2232 KiB
3Accepted2/23ms2284 KiB
4Accepted2/23ms2424 KiB
5Accepted2/22ms2512 KiB
6Accepted2/22ms2512 KiB
7Accepted2/23ms2768 KiB
8Accepted2/23ms2992 KiB
9Accepted2/24ms3416 KiB
10Accepted2/26ms3620 KiB
11Accepted2/26ms3576 KiB
12Accepted2/24ms3728 KiB
13Accepted2/237ms4836 KiB
14Accepted2/237ms8016 KiB
15Accepted2/261ms8084 KiB
16Accepted2/268ms6040 KiB
17Accepted2/274ms8092 KiB
18Accepted2/274ms6268 KiB
19Accepted2/272ms6484 KiB
20Accepted2/224ms6652 KiB
21Accepted2/261ms8988 KiB
22Accepted2/272ms6780 KiB