← November 2025 questions

NOVEMBER 2025 / ADVANCED / QUESTION 10

Question 10

Archived question

Try the question in your own editor, then check your output below.

THE QUESTION

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

PRACTICE CHECK

Try your answer.

The linked final-input download could not be retrieved (checked 28 October 2026). This checks the complete published sample, not the unavailable final input.

Run your program in your own editor, then paste its output below. This checks the stated output or checkpoint; it does not assess your full program. Practice attempts do not affect competition scores.

Use the three published sample cases. Enter the minimum merge counts in order.

Reveal worked answer

Your output

3
2
0

Try candidate counts of equal-sum contiguous groups from largest to smallest. If a partition exists, merges = original length − group count. All-zero arrays need no merges.

Source: Girls in Code SEA 2025 Fall Competition, 29 November 2025. Booklet created by Emily Xu and the GIC question authors. Shared for non-commercial educational use with attribution, as permitted in the booklet.