A14130 | Arena
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
$n$ heroes fight against each other in the Arena. Initially, the $i$ -th hero has level $a_i$ .
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 $100^{500}$ 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.
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 $100^{500}$ 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.
输入格式
The first line contains one integer $t$ ( $1 \le t \le 500$ ) — the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ( $2 \le n \le 100$ ) — the number of heroes. The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ( $1 \le a_i \le 100$ ), where $a_i$ is the initial level of the $i$ -th hero.
Each test case consists of two lines. The first line contains one integer $n$ ( $2 \le n \le 100$ ) — the number of heroes. The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ( $1 \le a_i \le 100$ ), where $a_i$ is the initial level of the $i$ -th hero.
输出格式
For each test case, print one integer — the number of possible winners among the given $n$ heroes.
输入输出样例
输入 #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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted