全WA求解
查看原帖
全WA求解
1073122
Accept__楼主2024/8/15 21:01

样例全部都过了,但是提交全WA 求大佬提点

#include<bits/stdc++.h>
using namespace std;
int n,sum=0;
bool cz;
int m,t,px=1,py=0;
struct Ticket{
	int price;
	int time;
	bool used;
}tic[100005];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>cz>>m>>t;
    	if(cz!=true)
    	{
    		py++;
    		tic[py].time=t+45;
    		tic[py].price=m;
    		tic[py].used=false;
    		sum+=m;
		}
		else
		{
			bool can=false;
			int nx=px;
			for(int j=px;j<=py;j++)
			{
				if(tic[j].time<t)
				{
					nx=j;
					continue;
				}
				if((tic[j].price>=m)&&(tic[j].used==false))
				{
					can=true;
					tic[j].used==true;
					break;
				}
			}
			px=nx;
			sum+=(!can)*m;
		}
	}
	cout<<sum<<endl;
   	return 0;
}
2024/8/15 21:01
加载中...