int main() { int t,i,j,k,n,s,m; scanf("%d",&t); pii p; while(t--){ v.clear(); scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d",&j,&k); v.push_back(ii(j,0)); v.push_back(ii(k,1)); } sort(v.begin(),v.begin()+2*n); s=0,m=-SENTINEL; for(i=0;i<2*n;i++){ p=v[i]; if(p.second==0)s+=1; else s-=1; m=max(m,s); } printf("%d\n",m); } return 0; }
int generatePairsDfs(vpii &pairs) { int index = findFirstNonAssignedIndex(); if (index >= 0) { int result = 0; for (int i = index+1; i < n; i++) { if (!assigned[i] && colors[index] == colors[i]) { assigned[i] = true; assigned[index] = true; pairs.push_back(make_pair(index, i)); result = max(result, generatePairsDfs(pairs)); assigned[i] = false; assigned[index] = false; pairs.pop_back(); } } return result; } else { return removeDishes(pairs); } }