作者:
那必须得是我了
,
2023-01-21 17:52:59
,
所有人可见
,
阅读 4
#include<iostream>
#include<algorithm>
#define x first
#define y second
using namespace std;
const int N = 1e5+10;
typedef pair<int, int> PII;
bool st[N];//是否在优先队列中
int last[N];//表示第i个店铺上一次有订单的时刻
int score[N];//表示第i个店铺当前的优先级
int n,m,T;
PII order[N];//时间-店名
int main()
{
scanf("%d%d%d", &n,&m,&T);
for(int i=0;i<m;i++) scanf("%d%d", &order[i].x,&order[i].y);
sort(order,order+m);
for(int i=0;i<m;)
{
int j=i;
while(j<m && order[j] == order[i]) j++;
int t=order[i].x, id=order[i].y, cnt=j-i;
i=j;
score[id] -=t-last[id]-1;
if(score[id] < 0) score[id] = 0;
if(score[id] <= 3) st[id] = false;
score[id] += cnt*2;
if(score[id] > 5) st[id] = true;
last[id] = t;
}
for(int i=1;i<=n;i++)
{
if(last[i] < T)
{
score[i] -= T - last[i];
if(score[i] <= 3) st[i] = false;
}
}
int ans=0;
for(int i=1;i<=n;i++) ans+=st[i];
cout<<ans<<endl;
return 0;
}