0分,求hack
查看原帖
0分,求hack
1321894
xukongming楼主2025/1/16 21:45
#include<bits/stdc++.h>
using namespace std;
#define N 100100
int x,n,cnt=1;
long long ans;
priority_queue<int> q;
struct node
{
	int a,b,c;
}abc[N];
int cmp(node a1,node a2)
{
	return a1.b<a2.b;
}
int main(){
	scanf("%d%d",&x,&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&abc[i].a,&abc[i].b,&abc[i].c);
	}
	sort(abc+1,abc+1+n,cmp);
	for(int i=1;i<=x;i++)
	{
		if(i<=abc[cnt].b)
		{
			q.push(abc[cnt].a);
			abc[cnt].c--;
			if(abc[cnt].c==0)
			{
				cnt++;
			}
			if(cnt>n&&i!=x)
			{
				printf("-1");
				return 0;
			}
		}
		else
		{
			while(abc[cnt].b<i)
			{
				while(abc[cnt].a<q.top()&&abc[cnt].c)
				{
					q.pop();
					q.push(abc[cnt].a);
					abc[cnt].c--;
				}
				cnt++;
				if(cnt>n)
				{
					printf("-1");
					return 0;
				}
			}
			q.push(abc[cnt].a);
		}
	}
	while(!q.empty())
	{
		ans+=q.top();
		q.pop();
	}
	printf("%lld",ans);
	return 0;
}

试了很多hack数据,都能过掉,但交上去就全WA

2025/1/16 21:45
加载中...