求助
查看原帖
求助
783941
Jamison楼主2022/9/15 12:34

样例全对,加上去WA+TLE

#include<bits/stdc++.h>
#define INF 100005
using namespace std;
struct csp{
	long long temp,price,t;
}a[INF];
long long n,l[INF],d[INF];
long long p,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%lld %lld %lld",&a[i].temp,&a[i].price,&a[i].t);
	for(int i=1;i<=n;i++){
		if(a[i].temp)
		{
			for(int j=1;j<=p;j++){
				if(a[i].t-l[j]>45 && l[j]!=0) ans+=a[i].price;
				else l[j]=0;
			}
				
		}
		else{
			l[++p]=a[i].t;
			ans+=a[i].price;
		}
	}
	cout<<ans;
	return 0;
}
2022/9/15 12:34
加载中...