第十届蓝桥杯省赛C++A/C组 外卖店优先级 篮球杯,奇奇怪怪の模拟


真的很奇怪,考场上应该很难想到吧,不过一想到暴力mle还能90分我就...

#include
#define rep(i,x,n) for(int i=x;i<=n;i++)
using namespace std;

const int N = 1e5+10;

int n,m,t;
int a[N];
int pre[N];
int st[N];
struct node{
	int t,id;
}q[N];

bool cmp(node a,node b) {
	if(a.t==b.t) return a.id> n >> m >> t;
	rep(i,1,m) cin >> q[i].t >> q[i].id;
	
	sort(q+1,q+m+1,cmp);
	
	int i=1;
	while(i<=m)
	{
		int j=i;
		while(j<=m&&q[i].id==q[j].id&&q[i].t==q[j].t) j++;
		int cnt=j-i;//同一家店铺订单的个数
		int cur=q[i].t,id=q[i].id;
		i=j;
		a[id]-=cur-pre[id]-1;//算了减少的数量
		pre[id]=cur;
		if(a[id]<0) a[id]=0;
		if(a[id]<=3) st[id]=0;
		a[id]+=cnt*2;
		if(a[id]>5) st[id]=1;
	}
	int ans=0;
	rep(id,1,n)
	{
		if(pre[id]!=t) a[id]-=t-pre[id];
		if(a[id]<=0) a[id]=0;
		if(a[id]<=3) st[id]=0;
		ans+=st[id];
	}
	cout << ans;
}