Dws_t7760 @ 2023-10-04 09:30:40
日志并不是按照时间顺序给出的,需要按照时间排序一遍再进行统计
by UESTCxx @ 2024-01-25 18:42:58
#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;
}
by UESTCxx @ 2024-01-25 18:43:45
我的代码就7WA咯,但是不知道为什么..