40分求调
查看原帖
40分求调
528751
wanys楼主2024/7/12 14:38
#include <iostream>
using namespace std;
struct test{
	int bos;
	int price;
	int t;
	int use;
};test a[500001];
struct testz{
	int p;//是否有 
	int pt;//时间
	int pr;//价格 
	int id;
};testz te[100001];
int main(){
	freopen("transfer.in","r",stdin);
	freopen("transfer.out","w",stdout);  
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].bos>>a[i].price>>a[i].t;
	}
	int ans=0,t=1; 
	for(int i=1;i<=n;i++){
		if(a[i].bos==0){
			ans+=a[i].price;
			te[t].id=i;
			te[t].p=1;
			te[t].pr=a[i].price;
			te[t].pt=a[i].t;
			t++;
			a[i].use=1;
		} 
	}
	for(int i=1;i<=n;i++){
		if(a[i].bos==1){
			for(int j=1;j<t;j++){
				if((a[i].t-te[j].pt)<=45&&a[i].price<=te[j].pr&&te[j].p==1&&a[i].use==0&&a[i].t>te[j].pt){
					te[j].p=0;
					a[i].use=1;
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(a[i].use==0){
			ans+=a[i].price;
			a[i].use=1;
		}
	}
	cout<<ans;
	return 0;
}

qwq对了4个点,其他点TLE

2024/7/12 14:38
加载中...