第7个测试点WA了,求大佬ヽ( ̄ω ̄( ̄ω ̄〃)ゝ
查看原帖
第7个测试点WA了,求大佬ヽ( ̄ω ̄( ̄ω ̄〃)ゝ
1079064
UESTCxx楼主2024/1/25 18:28
#include<bits/stdc++.h>
using namespace std;
multimap<int,int>hahash;
struct cmp{  
    bool operator()(const pair<int, int>& a, const std::pair<int, int>& b) {  
    	if (a.first == b.first) {  
            return a.second > b.second;
        }  
        return a.first > b.first;
	}  
}; 
set<int>ans;
priority_queue<pair<int,int>,vector<pair<int, int>>,cmp>heheap;
int main(){
	ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
	int n,d,k;cin>>n>>d>>k;
	
	
	for(int i=0;i<n;++i){ 
		int time,index;
		cin>>time>>index;
		heheap.push(make_pair(index,time));
	}
	
	while(!heheap.empty()){
		int time=heheap.top().second+d;
		int index=heheap.top().first;
		int counter=1;
		heheap.pop();
		while(!heheap.empty()&&heheap.top().first==index&&heheap.top().second<time){
			heheap.pop();++counter;
		}
		if(counter>=k)ans.insert(index);
	}
	for(const auto& x:ans)cout<<x<<endl;
	return 0;
}

第七个测试点WA了是为什么啊???大佬看看

2024/1/25 18:28
加载中...