求助40分超时
查看原帖
求助40分超时
763794
aikyon_lz2022楼主2023/9/10 17:24
#include<bits/stdc++.h>
using namespace std;
int yhjjq[114514],yhjsj[114514];
bool pd=0;
int main(){
	int n,gjdt,price,time,cnt=1,ansprice=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>gjdt>>price>>time;
		if(gjdt==0){
			yhjjq[cnt]=price;
			yhjsj[cnt]=time+45;
			cnt++;
			ansprice+=price;
		}
		if(gjdt==1)
		{
			if(cnt>1){
				for(int i=1;i<=cnt-1;i++)
				{
					if(yhjjq[i]>=price&&yhjsj[i]>=time)
					{
						yhjjq[i]=0;
						yhjsj[i]=0;
						pd=1;
						break;
					}
				}
				if(!pd)ansprice+=price;
				pd=0;
			}
			else ansprice+=price;
		}
	}
	cout<<ansprice;
	return 0;
}
2023/9/10 17:24
加载中...