Source Code
#include <bits/stdc++.h>
using namespace std;


string solve(){
        int n , e , k;


    cin >> n >> e >> k;
        int arr[n];
    int i=0;
    int counter=0;
    for(; i<n/k; i++){
        for(int j=0; j<k; j++){
            arr[counter] = (i+1);
            counter++;
        }
    }

    ++i;
    for(int j=0; j<n%k; j++) {arr[counter] = i; counter++;}

    cout << endl;
    for(int i=0; i<n; i++){
        int minRange = max(1 ,(i+1)-e)-1;
        int maxRange = min(n ,(i+1)+e)-1;
        int maxNumber=0, maxNumberInx=0;
        for(int u=minRange; u<=maxRange; u++){
            if(arr[u] > maxNumber) {maxNumber=arr[u]; maxNumberInx = u;}
        }
        if(maxNumber==0) return "No";
        else arr[maxNumberInx] = 0;
    }

    return "Yes";
}

int main(){
cout << solve();
return 0;
}
Copy
Scientific Study hamzah_lababidi
GNU G++14
180 ms
262.1 MB
Memory Limit Exceeded