蒟蒻真的不会了,样例二过了样例一却没过
查看原帖
蒟蒻真的不会了,样例二过了样例一却没过
506649
昊轩啥也不是楼主2021/10/3 13:25

改了好多次,样例一还是输出三十,求助QAQ

#include<bits/stdc++.h>
using namespace std;
struct fuck{
	int hmbb,p,t;
}a[100005];
int main(){
	int n,i,j,ans=0,sum=1,hhh=1,f,sale=0,time=0,b[100005]={0};
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i].hmbb>>a[i].p>>a[i].t;
		
		if(a[i].hmbb==0){
			sale++;
			b[sum++]=a[i].t;
			ans+=a[i].p;
			continue;
		}
		
		if(a[i].hmbb==1){
		f=a[i].t;
		if(sale==0){
			ans+=a[i].p;
			continue;
		}
		else{
		for(j=hhh;j<sum;j++){
			if(f-b[j]<=45){
				sale--;
				hhh++;
				break;
			}
			else hhh++;
			
			if(hhh==sum){
				ans+=a[i].p;
				sale=0;
				break;
			}
		}
	}
}
}
cout<<ans;
return 0;
}
2021/10/3 13:25
加载中...