Ten Thousand Empty Cases

The constraint block reads:

1 <= t <= 10^4                       (number of test cases)
1 <= n <= 2*10^5                     (array length in one case)
the sum of n over all test cases does not exceed 2*10^5

Your per-case algorithm is O(nlog⁡n)O(n \log n). What is your real budget, and where is the risk?

A

The sum bound adds nothing, since n≤2⋅105n \le 2 \cdot 10^5 already caps every case.

B

Total work across the whole run is bounded by O ⁣((∑n)log⁡n)≈3.5⋅106O!\left(\left(\sum n\right) \log n\right) \approx 3.5 \cdot 10^6, so the algorithm is fine. The risk is any per-case work that depends on the maximum nn rather than this case's nn: clearing a fixed 2⋅1052 \cdot 10^5 array at the top of each case costs 104⋅2⋅105=2⋅10910^4 \cdot 2 \cdot 10^5 = 2 \cdot 10^9.

C

The budget is per test case, so you get roughly 10810^8 operations for each of the up to 10410^4 cases.

D

With tt as large as 10410^4 the binding constraint is tt, so you need an O(1)O(1) answer per case.