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

int main(){
    int n , e , k;
    
    cin >> n >> e >> k;
    vector<int> arr;
    int i=0;
    for(; i<n/k; i++){
        for(int j=0; j<k; j++){
            arr.push_back(i+1);
        }
    }
    
    ++i;
    for(int j=0; j<n%k; j++) arr.push_back(i);

    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
377 ms
262.1 MB
Memory Limit Exceeded