130692025-01-05 14:43:28szabelrFasor (40)cpp17Time limit exceeded 22/40300ms1172 KiB
#include <iostream>
using namespace std;
int fak[200001]{ 0 };
int main()
{
    long long n, k, h,max=0;
    cin >> n>>k;
    for (int i = 1; i <= n; i++) {
        cin >> h;
        fak[i] = h;
        if (h > max)
            max = h;
    }
    for (int i = 1; i <= n; i++) {
        if(fak[i]>=fak[i-1]){
        int ln = 0;
        for (int y = i; y <= i + k and y<=max; y++) {
            if (fak[y] > fak[i]) {
                ln = 1;
                break;
            }
                
            
        }
        if (ln == 0) {
            for (int y = i; y > i - k and y > 0; y--) {
                if (fak[y] > fak[i]) {
                    ln = 1;
                    break;
                }
            }
        }
        if (ln == 0) {
            cout << i;
            break;
        }
        }
    }

}
SubtaskSumTestVerdictTimeMemory
base22/40
1Accepted0/01ms512 KiB
2Accepted0/04ms424 KiB
3Accepted2/21ms320 KiB
4Accepted2/21ms320 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms560 KiB
7Accepted2/21ms320 KiB
8Accepted2/22ms320 KiB
9Accepted2/24ms424 KiB
10Accepted2/24ms376 KiB
11Accepted2/24ms436 KiB
12Accepted2/23ms320 KiB
13Time limit exceeded0/2300ms608 KiB
14Time limit exceeded0/2300ms740 KiB
15Wrong answer0/254ms1104 KiB
16Time limit exceeded0/2300ms944 KiB
17Time limit exceeded0/2275ms1172 KiB
18Time limit exceeded0/2268ms1080 KiB
19Time limit exceeded0/2215ms1080 KiB
20Wrong answer0/219ms740 KiB
21Wrong answer0/254ms1080 KiB
22Accepted2/268ms1080 KiB