title: For each label in one array set the first k occurrences to False in another array
body: <p>I have two (sorted) arrays, A and B, of different lengths each containing unique labels that are repeated a number of times.
  The count for each label in A is less than or equal to that in B.
  All labels in A will be in B, but some labels in B do not appear in A.</p>
  
  <p>I need an object the same length as B where, for each label <code>i</code> in A (which occurs <code>k_i</code> times), the first <code>k_i</code> occurrences of label <code>i</code> in B need to be set to <code>False</code>.
  The remaining elements should be <code>True</code>.</p>
  
  <p>The following code gives me what I need, but if A and B are large, this can take a long time:</p>
  
  <pre><code>import numpy as np
  
  # The labels and their frequency
  A = np.array((1,1,2,2,3,4,4,4))
  B = np.array((1,1,1,1,1,2,2,3,3,4,4,4,4,4,5,5))
  
  A_uniq, A_count = np.unique(A, return_counts = True)
  new_ind = np.ones(B.shape, dtype = bool)
  for i in range(len(A_uniq)):
      new_ind[np.where(B == A_uniq[i])[0][:A_count[i]]] = False
  
  print(new_ind)
  #[False False  True  True  True False False False  True False False False
  #  True  True  True  True]
  </code></pre>
  
  <p>Is there a faster or more efficient way to do this? I feel like I may be missing some obvious broadcasting or vectorized solution.</p>