5 CPU's Task scheduling N process
Read through and bookmark the C++ Standard Guidelines.  Numbers I note later are citations from this.

Don’t write using namespace std;.

You can, however, in a CPP file (not H file) or inside a function put individual using std::string; etc.  (See SF.7.)



#define MAXN 500


Don't use #define for constants or "functions" (⧺ES.31).



void recurse( int task_idx, int cpus_used_so_far, int  exit_time_of_task_in_CPUs[] ){


That last parameter is a pointer, with the implication that you are passing a pointer to the first of contiguous elements.  Don’t pass unknown-sized arrays like that.  

(Reading ahead…) since it is of fixed size known at compile time, define it as a std::array instead, both the actual array in main and the parameter (by reference).



int min_cpus_used = 6;

int exit_time_of_task_in_CPUs[5]={0};

if (cpus_used_so_far+1 &lt;= 5){

if(min_cpus_used==6){


Hard-coded magic numbers: are these all related?  Define a constant instead of sprinkling these throughout the code.



Let’s see… cpus_used_so_far is not changed within the function, just passed a different value when recursing, right?  It would be helpful for readability and analysis to mark it const in the declaration.

    if (cpus_used_so_far+1 &lt;= 5){
            ⋮
    }else{
        return ;
    }


That took me a moment to figure out what the else return was doing at the end of the function just before the closing braces.  This would be much clearer if you invert the logic:  put the exceptional case first, in the manner of precondition testing.

if (cpus_used_so_far+1 &gt; 5)  return;
⋮


Note that there is no further indenting of the regular code, since it is not nested anymore — it is the main-line of code.



cin.tie(NULL);


Don’t use the C macro NULL.  For a null pointer, it is the keyword nullptr.

    cout&lt;&lt; -1 &lt;&lt;endl;


Don’t use endl.  Just use \n.