我用插入得了90分,#18和#19 TLE了,看题解好像是桶排,不过没怎么看懂,有大佬能解释一下这道题桶排的思路吗?
这是90pts代码,好像不能优化了
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,w,a[100005],num,u;
int main(){
cin>>n>>w;
a[0]=INT_MAX;
for(int p=1;p<=n;p++)
{
u=max(1,p*w/100);
cin>>num;
for(int i=p;i>=0;i--)
{
if (num<a[i]){
a[i+1]=num;
break;
}
else{
a[i+1]=a[i];
}
}
cout<<a[u]<<' ';
}
return 0;
}