Text from the official booklet. Refer to the PDF for original mathematical notation, formatting, and linked input files. Printed samples and inputs are reproduced as published.
Dr. Zorlock, the evil alien scientist, has unleashed robotic drones to invade Earth! Agent Nova, Earth’s top defender, is tasked with monitoring how many drones appear in each surveillance zone. There are N surveillance zones (1 ≤ N ≤ 105), and Nova logs that ai drones appeared in the i-th zone (0 ≤ ai ≤ 106). The total number of drones detected in a single test case is guaranteed to be at most 106. However, Agent Kira wants to sabotage the report. She wants it to look like the invasion is perfectly coordinated — that every zone has the same number of enemy drones — so Earth’s headquarters will panic and blame Nova. Kira can only alter the report by merging two adjacent zones. For example, if a = [1, 2, 3, 4, 5], and she merges the 2nd and 3rd zones, the report becomes: [1, 5, 4, 5]. Task Determine the minimum number of merges Kira needs to perform so thatall remaining values in the report are equal . Input Format • The first line contains T (1 ≤ T ≤ 10), the number of test cases. • Each test case begins with a line containing N . • The next line contains a1, a2, . . . , aN . It is guaranteed that: • The sum of all ai within a single test case is at most 10 6, • The total sum of N over all test cases is at most 10 5. Output Format Output T lines, where each line contains a single integer: the minimum number of merges required for that test case. Sample Input 3 6 1 2 3 1 1 1 3 2 2 3 5 0 0 0 0 0 Sample Output 3 2 0 Question Input File: • Input: https://shorturl.at/rbrBh