Codeforces Round 1057 (Div. 2)
A
Circle of Apple Trees
Codeforces
800
原题
←B →
翻译中…

There are $n$ apple trees arranged in a circle. Each tree bears exactly one apple, and the beauty of the apple on the $i$-th tree is given by $b_i$ for all $1\le i\le n$. You start in front of tree $1$.

翻译中…

At each tree, you may choose to either eat the apple or skip it. After making your choice, you move to the next tree: from tree $i$, you move to tree $i+1$ for $1 \le i \le n - 1$, and from tree $n$, you move back to tree $1$. This process continues indefinitely as you move through the trees in a cycle.

翻译中…

However, you have a special condition: you may only eat an apple if its beauty is strictly greater than the beauty of the last apple you ate. For example, if $b = [2, 1, 2, 3]$ and you eat the apple on tree $1$ (beauty $2$), you cannot eat the apples on trees $2$ and $3$ because their beauties are not greater than $2$. However, you may eat the apple on tree $4$ since $b_4 = 3 \gt 2$.

翻译中…

Note that you are allowed to skip an apple when you first encounter it, and you can choose to eat it later on a subsequent cycle.

翻译中…

Your task is to determine the maximum number of apples you can eat if you make optimal decisions on when to eat or skip each apple.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($1 \le n\le 100$) — the number of apple trees.

翻译中…

The second line of each test case contains $n$ integers $b_1, b_2, \ldots, b_n$ ($1\le b_i\le n$) — the beauty of the apples on the trees.

翻译中…

Note that there are no constraints on the sum of $n$ over all test cases.

翻译中…

Output

翻译中…

For each test case, output a single integer representing the maximum number of apples you can eat.

翻译中…

Note

翻译中…

In the first test case, since all apples have the same beauty, no matter which apple you eat first, you cannot eat any others afterward. Hence, the maximum number of apples that you can eat is $1$.

翻译中…

In the second test case, you can eat four apples as follows:

翻译中…
  • At tree $1$, skip the apple.
  • At tree $2$, skip the apple.
  • At tree $3$, skip the apple.
  • At tree $4$, eat the apple (beauty $1$).
  • At tree $5$, eat the apple (beauty $2$).
  • At tree $1$, skip the apple. You are not allowed to eat the apple as its beauty ($b_1 = 1$) is not greater than the beauty of the last apple you ate ($b_5 = 2$).
  • At tree $2$, eat the apple (beauty $4$).
  • At tree $3$, eat the apple (beauty $5$).
翻译中…

It can be proven that it is not possible to eat all five apples; hence, the maximum number of apples that you can eat is $4$.

翻译中…

样例

Input #1
3
4
2 2 2 2
5
1 4 5 1 2
6
5 4 2 1 2 3
Output #1
1
4
5
InputCopy OutputCopy
题目信息
题号
2153A
时间限制
1 s
内存限制
256 MB
标签
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。