65132023-12-05 18:33:30antiFasor (40)cpp14Runtime error 38/4075ms6608 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);
    }

    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
base38/40
1Accepted0/03ms1808 KiB
2Accepted0/04ms2292 KiB
3Accepted2/23ms2272 KiB
4Accepted2/23ms2508 KiB
5Accepted2/22ms2612 KiB
6Accepted2/22ms2608 KiB
7Accepted2/23ms2668 KiB
8Accepted2/23ms2700 KiB
9Accepted2/24ms3052 KiB
10Accepted2/26ms3256 KiB
11Accepted2/26ms3348 KiB
12Accepted2/24ms3576 KiB
13Accepted2/237ms4656 KiB
14Runtime error0/235ms4868 KiB
15Accepted2/257ms5884 KiB
16Accepted2/267ms6020 KiB
17Accepted2/272ms6212 KiB
18Accepted2/275ms6100 KiB
19Accepted2/272ms6260 KiB
20Accepted2/223ms5500 KiB
21Accepted2/259ms6608 KiB
22Accepted2/272ms6564 KiB