全WA求助!
查看原帖
全WA求助!
305925
Liu45318楼主2020/10/3 21:02
#include<iostream>
using namespace std;

int n,t,price;
bool b,vis[100001];
short pt[100001],pp[100001],first=1,last=0;
long int ans=0;

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		while (first<=last&&vis[first]) first++;
		
		cin>>b>>price>>t;
		
		if (!b) //subway
		{
			ans+=price;
			pt[++last]=t;
			pp[last]=price;
		}
		
		else if (b) //bus
		{
			if (first>last) //empty
				ans+=price;
			
			else 
			{
				bool flag=false;
				for (int j=first;j<=last;j++)
				{
					 if (pt[j]+45<t&&!vis[j]) //Nope
					 {
					 	vis[j]=true;
					 	ans+=price;
					 	flag=true;
					 }
					 else if (pp[j]>=price&&!vis[j])
					 {
					 	vis[j]=true;
					 	flag=true;
					 	break;
					 }
				}
				if (!flag) ans+=price;
			}
		}
		
		//cout<<ans<<' '<<first<<' '<<last<<endl<<endl;
	}
	cout<<ans;
	return 0;
}		

两个样例都过去了,可是竟然全WA!?

2020/10/3 21:02
加载中...