AcWing 1241. 外卖店优先级---多写几遍
原题链接
简单
作者:
会飞的泡泡
,
2021-03-23 22:37:11
,
所有人可见
,
阅读 455
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair<int,int> PII;
int n,m,T;
const int maxn=1e5+10;
PII order[maxn];
int score[maxn],last[maxn];
bool st[maxn];
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[i]==order[j])j++;
int t=order[i].x,id=order[i].y;
int 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]+=2*cnt;
last[id]=t;
if(score[id]>5)st[id]=true;
}
for(int i=1; i<=n; i++){
if(last[i]<T){
score[i]-=T-last[i];///
if(score[i]<=3)st[i]=false;
}
}
int res=0;
for(int i=1; i<=n; i++)if(st[i])res++;
cout<<res;
}