悬赏关注*1,大佬们救急orz
查看原帖
悬赏关注*1,大佬们救急orz
823725
EZAIJ楼主2023/4/4 21:19

过了样例,但一个没ac。。

#include<bits/stdc++.h>
using namespace std;

#define N 200010

int com[N],n,m;
struct{
	int t,code,shi,s;
}q[N],pro[N];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&com[i]);
	for(int i=0;i<m;i++) scanf("%d%d%d%d",&q[i].t,&q[i].code,&q[i].shi,&q[i].s );
	int i=0,j=0,h=0;
	while(m--)
	{
		while(h!=0&&q[j].t-pro[i].t>=pro[i].shi)//不确定是>还是>=
		{
			com[pro[i].code]+=pro[i].s;
			i++;
		 } 
		if(com[q[j].code]-q[j].s>=0) 
		{
			printf("%d\n",com[q[j].code]-q[j].s);
			com[q[j].code]-=q[j].s;
			pro[h++]={q[j].t,q[j].code,q[j].shi,q[j].s};
		}
		else
			printf("-1\n");
		j++;
	}
	return 0;
}
2023/4/4 21:19
加载中...