模拟爆0求助
查看原帖
模拟爆0求助
1030865
letusgo楼主2024/10/5 00:14
#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e5+100;

struct node{
	int time, price;
};

int a[maxn][4];
vector<node> v;
bool vis[maxn];

int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= 3; j++){
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(a[i][1] == 0){ 
			v.push_back({a[i][3], a[i][2]});
			ans += a[i][2];
		}
		else{
			bool f = false;
			for(int j = 0; j < v.size(); j++){
				
 				if(a[i][3] - v[j].time <= 45 && a[i][2] <= v[j].price && !vis[i]){
					f = true; vis[i] = true;
					break;
				}
			}
			
			if(!f) ans += a[i][2];
		}
	}

	cout << ans;

	return 0;
}
2024/10/5 00:14
加载中...