优先队列,T3个点,求助
查看原帖
优先队列,T3个点,求助
553772
GLESENA楼主2023/10/14 20:42
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	int op;
	priority_queue<int, vector<int>, greater<int> > pq;
	cin>>op;
	pq.push(op);
	for(int i=2;i<=n;i++)
	{
		cin>>op;
		pq.push(op);
	}
	for(int i=1;i<k;)
	{
		//cout<<pq.top()<<"\n";
		op=pq.top();
		pq.pop();
		if(op!=pq.top())
		{
			i++;
		}
	}
	cout<<pq.top();
	return 0;
}

请问时间复杂度不应该是O(n_l$$_o$$_gn)吗,为什么会TLE?

2023/10/14 20:42
加载中...