Redirecting arriving customers to the nearest empty queue
I see some things that may help you improve your code.

Don't abuse using namespace std

Putting using namespace std within your program is generally a bad habit that you'd do well to avoid.  

Check for errors

It may not be part of your assignment, but you should know that real programs should check for errors and handle them appropriately.

Use a function

Right now, everything is in main but we could make things a little more clear by creating a function.  Specifically, as each customer arrives at a register, they need to find the nearest open register.  This suggests a function: findNearestOpenRegister which could take a proposed register as an argument.  However, this function would have to get a number of other things passed to it which suggests a further refinement, described in the next suggestion.

Use an object

We can make the main code cleaner by using an object to represent the array of cashiers at a store.  I'd probably write it like this:

// represents a linear array of checkout registers at a store
class Checkout {
public:
    Checkout(int registerCount)
    : unoccupied(registerCount, true)
    {}
    int arrive(int r) { 
        int lo, hi;
        for (lo = hi = r; lo &gt;= 0 || hi &lt; unoccupied.size(); --lo, ++hi) {
            if (lo &gt;= 0 &amp;&amp; unoccupied[lo]) {
                unoccupied[lo] = false;
                return lo;
            } else if (hi &lt; unoccupied.size() &amp;&amp; unoccupied[hi]) {
                unoccupied[hi] = false;
                return hi;
            }
        }
        return ERROR;   // this is an error condition!
    }
    int leave(int r) { 
        if (unoccupied[r]) 
            return ERROR;
        unoccupied[r] = true; 
        return r;
    }
    static constexpr int ERROR = -1;
private:
    std::vector &lt;bool&gt; unoccupied;
};


Now the main function can use the object:

int main () {
    int n;
    int m; 

    std::cin &gt;&gt; n &gt;&gt; m; 
    Checkout reg(n);

    for (int i = 0; i &lt; m; ++i) {
        int checkout;
        char action;
        std::cin &gt;&gt; action &gt;&gt; checkout;
        --checkout; // checkout is 1-based in input, zero-based internally
        switch(action) {
            case 'C':  // someone comes to the register
                checkout = reg.arrive(checkout); 
                if (checkout == Checkout::ERROR) {
                    std::cout &lt;&lt; "Error: no free registers in line " &lt;&lt; i+2 &lt;&lt; ".\n";
                    return 1;
                }
                std::cout &lt;&lt; ++checkout &lt;&lt; '\n';
                break;
            case 'L':  // someone leaves the register
                checkout = reg.leave(checkout); 
                if (checkout == Checkout::ERROR) {
                    std::cout &lt;&lt; "Error: attempt to leave free register in line " &lt;&lt; i+2 &lt;&lt; ".\n";
                    return 1;
                }
                break;
            default:
                std::cout &lt;&lt; "Error: unknown action '" &lt;&lt; action &lt;&lt; "' in line " &lt;&lt; i+2 &lt;&lt; ".\n";
                return 1;
        }
    }
}


Note that error checking has been added, as per the earlier suggestion.  Also note that rather than storing the output, this version simply emits it as it's generated, avoiding the additional data structure that is otherwise needed.

Profile the program

If you find that the program is not performing as fast as you need, the first step should be to try to find out where the program is spending its time.  This can be done by several different methods.  I tend to use gprof.  Among the possibilities are using a different data structure.  See this question for an example.  Another possibility is to execute std::ios_base::sync_with_stdio(false);, but whether that speeds thing up or not is uncertain until you measure.