A user with rating and solved-problem count is recognized by everyone precisely when and hold for every .
Let and . The conditions are equivalent to and .
For each test case, compute both maxima and count users satisfying and .
The time complexity is per test case and overall. The space complexity is . Solution written by GPT6