题解:P7072 [CSP-J2020] 直播获奖
2025.2.16 by Xuancheng_Mao
桶排序,从高到低数即可。
代码:
#include<bits/stdc++.h>
using namespace std;
int n,w,cnt[605];
int main(){
ios::sync_with_stdio(false);
cin>>n>>w;
for(int i=1;i<=n;i++){
int scr;
cin>>scr;
cnt[scr]++;
int num=max(1,i*w/100),tmp=0;
for(int j=600;j>=0;j--){
tmp+=cnt[j];
if(tmp>=num){
cout<<j<<' ';
break;
}
}
}
return 0;
}
坑点:
1.for(int j=600;j>=0;j--)
是从高到低排,容易粗心写错。
2.要记得 break
。