0分,样例都过不了,求调!
查看原帖
0分,样例都过不了,求调!
1067416
wlx2012楼主2024/4/6 22:18

代码:

#include<bits/stdc++.h>
using namespace std;
struct del{
	int delmoney;
	int gettime;
	bool pop;
};
struct act{
	int upmoney;
	int dex;
	int uptime;
};
int n;
act input[10005];
del yyy[10005];
int money;
int l=1,r=0;
int main(){
	cin>>n;
	for(int i = 1;i<=n;i++){
		cin>>input[i].dex>>input[i].upmoney>>input[i].uptime;
	}
	for(int i = 1;i<=n;i++){
		if(input[i].dex==0){
			r++;
			money+=input[i].upmoney;
			yyy[r].delmoney=input[i].upmoney;
			yyy[r].gettime=input[i].uptime;
			yyy[r].pop=true;
		}
		else{
			bool flag = false;
			for(int i = l;i<=r;i++){
				if(input[i].uptime-yyy[i].gettime>45){
					l++;
				}
				else if(yyy[i].delmoney>input[i].upmoney&&yyy[i].pop==true){
					flag = true;
					yyy[i].pop = false;
					break;
				}
			}
			if(flag == false){
				money += input[i].upmoney;
			}
		}
		cout<<money<<" :";
		for(int i = 1;i<=r;i++){
			cout<<yyy[i].delmoney<<" "<<yyy[i].gettime<<" "<<yyy[i].pop<<"  ";
		} 
		cout<<endl;
	}
	cout<<money;
	return 0;
}
2024/4/6 22:18
加载中...