思路: 排个序, 按照给的数目把人分为一组,就可以得出最少人数
#includeusing 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); }}