A. Arena
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.
Input
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.
Output
For each test case, print one integer — the number of possible winners among the given n heroes.
输入样例
3
3
3 2 2
2
5 5
4
1 3 3 7
输出样例
1
0
3
解题思路
几个英雄决斗,找到最弱的,如果都是最弱的(菜鸡互啄)那就无法分出胜负
简单讲就是找到最弱的 比如我这种 用总数减去最弱的人的数量
AC代码
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int a[101];
int main()
{
int t;
cin>>t;
while(t--)
{
memset(a,0,sizeof a);
int n;
cin>>n;
int count1=101;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;
a[i]=x;
count1=min(count1,x);
}
int count2=0;
for(int i=1;i<=n;i++)
{
if(count1==a[i])
count2++;
}
cout<<(n-count2)<<endl;
}
}