题意: 给你N 个人, 每个人说出有多少人和他一队, 不包括他自己, 输出总人数最少值
思路: 排个序, 按照给的数目把人分为一组,就可以得出最少人数
#include<bits/stdc++.h>
using namespace std;
const int maxn = 50 + 13;
int Num[maxn];
int main()
{
int t, N;
scanf("%d",&t);
for(int kase = 1; kase <= t; ++kase)
{
scanf("%d",&N);
for(int i = 0; i < N; ++i)
scanf("%d",&Num[i]);
sort(Num,Num+N);
int Ans = 0;
for(int i = 0; i < N; ++i)
{
if(Num[i] == -1) continue ;
else {
int Now = Num[i];
Num[i] = -1;
for(int j = i+1; j <= i+Now && j < N; ++j)
{
if(Num[j] == Now)
Num[j] = -1;
}
Ans += (Now + 1);
}
}
printf("Case %d: %d\n",kase, Ans);
}
}