4,7,13WA求调,求大佬帮忙看一眼
查看原帖
4,7,13WA求调,求大佬帮忙看一眼
1189413
PURE_LOVE楼主2025/1/15 11:34
#include<bits/stdc++.h>
using namespace std;
int n;
float w;
map<int, int>arr;
int main()
{
	cin >> n >> w;
	int t=1, t1=1;
	int lind = 0;
	int temp = 0;
	cin >> temp;
	arr[temp] = 1;
	cout << temp << ' ';
	lind=temp;
	int index = 1;
	for (int i = 2; i <= n; i++)
	{

		cin >> temp;
		t = i * (w / 100);
		t = max(t, 1);
		if (arr.find(temp) == arr.end())
		{
			arr[temp] = 1;
		}
		else arr[temp] += 1;
		if (t == t1)
		{
			if (lind < temp && index == 1)
			{
				auto it =arr.upper_bound(lind);
				pair<int, int>tp = *it;
				lind = tp.first;
				index = arr[lind];
			}
			else if (lind < temp)
			{
				index--;
			}
		}
		else
		{
			if (lind>=temp)
			{
				if (arr[lind]>index)index++;
				else
				{
					auto it = arr.lower_bound(lind);
					it--;
					pair<int, int>tp = *it;
					lind = tp.first;
					index = 1;
				}
			}
		}
		t1 = t;
		cout << lind << ' ';
	}
}
2025/1/15 11:34
加载中...