title: searching why memory is not being allocated
body: <p>I Read all about the reasons for this <strong>error(SIGABRT)</strong> -> made this program using arrays and that gave me SIGSEGV. Please show me where have I asked for some memory which compiler cannot allocate or narrow it down to exact problem and where it resides??<br>
  Constraints are described below, and I've used <code>long long int</code></p>
  
  <ol>
  <li>1 ≤ T ≤ 100</li>
  <li>1 ≤ N, K ≤ 100,000</li>
  <li>1 ≤ sum of K over all test cases ≤ 100,000</li>
  <li>1 ≤ Ai, Di ≤ 1,000,000 for each valid i</li>
  <li>1 ≤ Bi ≤ C for each valid i</li>
  <li><p>Bi+1 &lt; Bi for each valid i</p>
  
  <pre><code>#include &lt;bits/stdc++.h&gt;
  using namespace std;
  typedef long long int ll;
  
  
  int main() {
  ll T;
  cin&gt;&gt;T;
  
  while(T--){
  
      ll N,K;
      cin&gt;&gt;N&gt;&gt;K;
  
      vector&lt;ll&gt; A(N,0);
      vector&lt;ll&gt; D(N,0);
      vector&lt;ll&gt; B(N,0);
  
      for(ll i=0; i&lt;N ; i++){             // O(N)
          cin&gt;&gt;A[i];
      }
  
      for(ll i=0; i&lt;N ; i++){             // O(N)
          cin&gt;&gt;D[i];
      }
  
      for(ll i=0; i&lt;K ; i++){             // O(K)
          cin&gt;&gt;B[i];
      }
  
      ll vect_size=0;
  
      for(ll i=0; i&lt;N ; i++)              // O(N)
          vect_size += D[i] ;
  
      //cout&lt;&lt;vect_size&lt;&lt;endl;
  
      vector&lt;ll&gt; cards(vect_size,0);
      ll sum=0;
  
  
      for(ll i=0; i&lt;N ; i++){
  
          for(ll j=0; j&lt;D[i] ; j++){
  
              cards[ sum+j ] = A[i] ;
          }
          sum+=D[i];
      }
  
  
     //sort(cards, cards+vect_size );                    // O(N.logN)  ::  N = vect_size
     sort(cards.begin(), cards.end());
  
      //----------------------game-begins-now-----------------------------------------
  
  
  
      ll left_lim=0;
      ll right_lim=vect_size-1;
      ll cur_size=vect_size;
  
      for(ll i=0; i&lt;K; i++){
  
          if( i%2==0 ){
  
                  left_lim += cur_size-B[i] ;
                  cur_size  = B[i];
  
          }
          else{
  
                  right_lim -= cur_size-B[i];
                  cur_size  = B[i];
          }            
  
  
  
  
      }
  
      sum=0;
  
  
  
      for(ll i=left_lim; i&lt;=right_lim; i++)
              sum += cards[i];
  
      cout&lt;&lt;sum&lt;&lt;"\n";
  
  
  }
  
  
  return 0;
  </code></pre>
  
  <p>}</p></li>
  </ol>