这是桶排序还是计数排序,啊啊啊
查看原帖
这是桶排序还是计数排序,啊啊啊
521302
landernal楼主2021/10/13 18:57
#include<bits/stdc++.h>
using namespace std;
int t[605];
int n,w;
int main()
{
	int x;
	cin>>n>>w;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		t[x]++;
		int sum=0;
		for(int j=600;j>=0;j--)
		{
			sum+=t[j];
			if(sum>=max(1,i*w/100))
			{
				cout<<j<<' ';
				break;
			}
		}
	}
	return 0;
 }
2021/10/13 18:57
加载中...