CF1705B Mark the Dust Sweeper

题目描述

给一个元素个数为 $n$ 的序列 $a$,你可以选出下标为 $i$ 和 $j(i

输入格式

第一行一个整数 $t$ 代表数据组数。 对于每组数据,第一行为一个整数 $n$ ;第二行 $n$ 个整数,第 $i$ 个数代表 $a_i$。

输出格式

对于每组数据输出一行一个整数,为最小的操作数。 $1 \le t\le 10^4,2 \le n\le 2\times 10^5,0 \le a_i \le 10^9$ 题目保证所有数据的 $n$ 之和不超过 $2\times 10^5$。

说明/提示

In the first case, one possible sequence of operations is as follows. - Choose $ i=1 $ and $ j=2 $ , yielding the array $ [1,1,0] $ . - Choose $ i=1 $ and $ j=3 $ , yielding the array $ [0,1,1] $ . - Choose $ i=2 $ and $ j=3 $ , yielding the array $ [0,0,2] $ . At this point, $ a_1=a_2=0 $ , completing the process.In the second case, one possible sequence of operations is as follows. - Choose $ i=4 $ and $ j=5 $ , yielding the array $ [0,2,0,1,1] $ . - Choose $ i=2 $ and $ j=3 $ , yielding the array $ [0,1,1,1,1] $ . - Choose $ i=2 $ and $ j=5 $ , yielding the array $ [0,0,1,1,2] $ . - Choose $ i=3 $ and $ j=5 $ , yielding the array $ [0,0,0,1,3] $ . - Choose $ i=4 $ and $ j=5 $ , yielding the array $ [0,0,0,0,4] $ . In the last case, the array already satisfies the condition.