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

// int const N = 1000000010;

int main(){
    int n , e , k;
    
    
    cin >> n >> e >> k;
        int arr[n+5];
    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 i=minRange; i<=maxRange; i++){
            if(arr[i] > maxNumber) {maxNumber=arr[i]; maxNumberInx = i;}
        }
        if(maxNumber==0) {cout << "No"; return 0;}
        else arr[maxNumberInx] = 0;
    }
    
    cout << "Yes";
    
    return 0;
}
Copy
Scientific Study hamzah_lababidi
GNU G++17
174 ms
262.1 MB
Memory Limit Exceeded