难道我的c++有问题???(急
查看原帖
难道我的c++有问题???(急
184271
l55584楼主2020/10/22 23:11
#include <iostream>
#include <cstdio>
using namespace std;
struct note
{
	bool kind;
	int time;
	int price;
};
note a[100001];
int n;
int head=0,tail=0;
note r[100001];
void push(note x)
{
	a[tail]=x;
	tail++;
}
note check()
{
	return a[head];
}
void pop()
{
	head++;
}
int ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>r[i].kind>>r[i].price>>r[i].time;
	for(int i=1;i<=n;i++)
	{
		if(r[i].kind==false)
		{
			push(r[i]);
			ans+=r[i].price;
		}
		else
		{
			while((r[i].time-check().time)>45)
			{
				pop();
			}
			bool flag=false;
			for(int j=head;j<tail;j++)
			{
				if((a[j].price>=r[i].price)&&(r[i].time-a[j].time)<=45)
				{
					flag=true;
					a[j].time=-999;
					break;
				}
			}
			if(flag==false) ans+=r[i].price;
		}
	}
	cout<<ans;
	return 0;
}

样例全过,评测0分(俩wa一片re)

我觉得程序大概没什么问题,问题肯定处在什么细节上……

急求各位有经验的dalao指出

2020/10/22 23:11
加载中...