其他分享
首页 > 其他分享> > P7072 [CSP-J2020] 直播获奖 vector+二分插入排序

P7072 [CSP-J2020] 直播获奖 vector+二分插入排序

作者:互联网

P7072 [CSP-J2020] 直播获奖 

#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<functional>
using namespace std;
vector <int> a;
int n,w,p;
int main()
{
	scanf("%d %d",&n,&w);
	for (int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if (a.empty())
		{
			a.push_back(x);
		}
		else
		{
			vector<int>::iterator wz;
			wz=upper_bound(a.begin(),a.end(),x,greater<int>());
			a.insert(wz,x);
			/*
			for(int j=0;j<a.size();j++)
			{
				printf("%d ",a[j]);
			}
			printf("\n"); 
			*/ 
		}
		p=max(1,i*w/100);
		printf("%d ",a[p-1]);
	}
}

  

标签:int,插入排序,CSP,J2020,vector,include,wz,P7072
来源: https://www.cnblogs.com/smghj/p/15982701.html