我已经不想讲什么了,求助大佬吧。。
查看原帖
我已经不想讲什么了,求助大佬吧。。
987906
159qqwewe楼主2023/9/9 14:09

全都是TLE+WA。。。

#include<bits/stdc++.h>
using namespace std;
struct kk{
	int way;
	int price;
	int t;
}g[1000000];
int times[100000000];
int p[10000000];
int main(){
	bool flag;
	int n,ans=0,tot=0,sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		flag=false;
		scanf("%d%d%d",&g[i].way,&g[i].price,&g[i].t);
		if(g[i].way==0){
			ans++,sum++,tot+=g[i].price,times[ans]=g[i].t,p[ans]=g[i].price;
			continue;
		}
		if(g[i].way==1 and sum>=1){
			for(int j=1;j<=ans;j++)
			    if(times[j]>=0 and g[i].t-times[j]<=45 and g[i].price<=p[j])
			        sum--,times[j]=-1,flag=true;
		if(flag==false)
			tot+=g[i].price;
	}
	printf("%d",tot);
	return 0;
} 

求助QwQ

2023/9/9 14:09
加载中...