CF1487A.Arena
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
n heroes fight against each other in the Arena. Initially, the i-th hero has level ai.
Each minute, a fight between two different heroes occurs. These heroes can be chosen arbitrarily (it's even possible that it is the same two heroes that were fighting during the last minute).
When two heroes of equal levels fight, nobody wins the fight. When two heroes of different levels fight, the one with the higher level wins, and his level increases by 1.
The winner of the tournament is the first hero that wins in at least 100500 fights (note that it's possible that the tournament lasts forever if no hero wins this number of fights, then there is no winner). A possible winner is a hero such that there exists a sequence of fights that this hero becomes the winner of the tournament.
Calculate the number of possible winners among n heroes.
n 位英雄在竞技场中相互对战。初始时,第 i 位英雄的等级为 ai。
每分钟发生一场两位不同英雄之间的对战。这两位英雄可任意选择(甚至可能与上一分钟对战的两位英雄完全相同)。
当两位等级相等的英雄对战时,无人获胜;当两位等级不同的英雄对战时,等级较高的英雄获胜,且其等级增加 1。
锦标赛的获胜者是首位赢得至少 100500 场战斗的英雄(注意:若没有任何英雄赢得如此多场战斗,则锦标赛可能永远持续下去,此时不存在获胜者)。一个可能的获胜者是指:存在某种对战序列,使得该英雄最终成为锦标赛的获胜者。
请计算 n 位英雄中可能的获胜者人数。
输入格式
The first line contains one integer t (1≤t≤500) — the number of test cases.
Each test case consists of two lines. The first line contains one integer n (2≤n≤100) — the number of heroes. The second line contains n integers a1,a2,…,an (1≤ai≤100), where ai is the initial level of the i-th hero.
第一行包含一个整数 t(1≤t≤500)—— 测试用例的数量。
每个测试用例由两行组成。第一行包含一个整数 n(2≤n≤100)—— 英雄的数量。第二行包含 n 个整数 a1,a2,…,an(1≤ai≤100),其中 ai 表示第 i 个英雄的初始等级。
输出格式
For each test case, print one integer — the number of possible winners among the given n heroes.
对于每个测试用例,输出一个整数——即给定的 n 位英雄中可能获胜者的数量。
输入输出样例
输入#1
3 3 3 2 2 2 5 5 4 1 3 3 7
输出#1
1 0 3
说明/提示
In the first test case of the example, the only possible winner is the first hero.
In the second test case of the example, each fight between the heroes results in nobody winning it, so the tournament lasts forever and there is no winner.
在示例的第一个测试用例中,唯一可能的获胜者是第一位英雄。
在示例的第二个测试用例中,英雄之间的每场战斗均无人获胜,因此锦标赛将永远持续下去,没有获胜者。
输入解题思路,AI测评打分。不知道怎么写?