50求条,帮助回关
查看原帖
50求条,帮助回关
1387445
wssnleh楼主2025/6/13 17:25
#include<bits/stdc++.h>
using namespace std;
long long n,sum,mon,z=1//开头;
struct t{
	int pri,time;
};
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0); 
	cin>>n;
	t tic[n];
	for(int i=1;i<=n;i++){
		int type,price,Time;
		cin>>type>>price>>Time;
		if(!type){
			tic[++sum].pri=price;
			tic[sum].time=Time+45;
			mon+=price;
		}//存票 
		else{
			mon+=price;
			for(int k=z;tic[k].time<Time;k++){
					tic[k].pri=-1;
					z=k;//本来应该是z=k+1,但是怎么写全wa了不知道为什么,所以说让z往前了1 
			}//扔票 
			for(int j=z;j<=sum;j++){
				if(tic[j].pri<0)continue;
				if(tic[j].pri>=price && tic[j].time>=Time){
					if(j==z) z+=1;
					tic[j].pri=-1;
					mon-=price;
					
//					cout<<"使用第"<<j<<"条优惠券"<<endl;
					break;
				}
			}//扫票 
		}
	}
//	for(int i=1;i<=sum;i++){
//		cout<<tic[i].pri<<" "<<tic[i].time<<endl;
//	}
	cout<<mon;
	return 0;
}
// 
2025/6/13 17:25
加载中...