- 取石子
摧毁
- 2025-10-3 8:58:39 @
#include<bits/stdc++.h>
using namespace std;
int a[1000010];
int main(){
int t;
cin>>t;
int sum=0;
int n,c,x;
for(int i=1;i<=t;i++){
cin>>n>>c;
int maxn=-2e9;
int sum=0;
for(int j=1;j<=n;j++){
cin>>x;
a[x]++;
if(x>maxn) maxn=x;
}
for(int j=1;j<=maxn;j++){
if(a[j]>=c){
a[j]=0;
sum+=c;
}else{
sum+=a[j];
a[j]=0;
}
}
cout<<sum<<"\n";
}
return 0;
}
0 条评论
目前还没有评论...
信息
- ID
- 116
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- 递交数
- 56
- 已通过
- 9
- 上传者