CF1678A.Tokitsukaze and All Zero Sequence
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Tokitsukaze has a sequence a of length n . For each operation, she selects two numbers ai and aj ( i=j ; 1≤i,j≤n ).
- If ai=aj , change one of them to 0 .
- Otherwise change both of them to min(ai,aj) .
Tokitsukaze wants to know the minimum number of operations to change all numbers in the sequence to 0 . It can be proved that the answer always exists.
输入格式
The first line contains a single positive integer t ( 1≤t≤1000 ) — the number of test cases.
For each test case, the first line contains a single integer n ( 2≤n≤100 ) — the length of the sequence a .
The second line contains n integers a1,a2,…,an ( 0≤ai≤100 ) — the sequence a .
输出格式
For each test case, print a single integer — the minimum number of operations to change all numbers in the sequence to 0 .
输入输出样例
输入#1
3 3 1 2 3 3 1 2 2 3 1 2 0
输出#1
4 3 2
说明/提示
In the first test case, one of the possible ways to change all numbers in the sequence to 0 :
In the 1 -st operation, a1<a2 , after the operation, a2=a1=1 . Now the sequence a is [1,1,3] .
In the 2 -nd operation, a1=a2=1 , after the operation, a1=0 . Now the sequence a is [0,1,3] .
In the 3 -rd operation, a1<a2 , after the operation, a2=0 . Now the sequence a is [0,0,3] .
In the 4 -th operation, a2<a3 , after the operation, a3=0 . Now the sequence a is [0,0,0] .
So the minimum number of operations is 4 .