题目:http://codeforces.com/problemset/problem/651/B
代码:
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int t;
int cmp(int b[1005])
{
for(int i=0; i<t; i++)
{
if(b[i]!=0)
return 1;
}
return 0;
}
int main()
{
scanf("%d",&t);
int a[1005];
for(int i=0; i<t; i++)
{
scanf("%d",&a[i]);
}
if(t==1)
{
printf("0\n");
return 0;
}
sort(a,a+t);
int ans=0;
while(cmp(a))
{
sort(a,a+t);
for(int i=1; i<t; i++)
{
if(a[i]>a[i-1]&&a[i-1]!=0)
{
ans++;
a[i-1]=0;
}
if(i==t-1)
a[i]=0;
}
}
printf("%d\n",ans);
}
2A。这都能水过。不可思议。