45分求助
查看原帖
45分求助
1335758
wywys楼主2025/7/25 14:11
#include <iostream>
using namespace std;
typedef long long ll;

const int N = 1e6 + 10;
int n;

struct T{
	int car, price, time;
}a[N];

int main()
{
	cin >> n;
	int m = 0;
	ll ans = 0;
	for(int i = 1; i <= n; i ++ ){
		int c, p, t;
		cin >> c >> p >> t;
		if(c == 0){
			ans += p;
			m ++;
			a[m].price = p;
			a[m].time = t + 45;
		} else{
			bool flag = false;
			for(int j = 1; j <= m; j ++ ){
				if(a[j].price >= p && a[j].time >= t){
					a[j].price = 0;
					flag = true;
					break;
				}
			}
			if(!flag) ans += p;
		}
	}
	cout << ans << "\n";
	return 0;
}
2025/7/25 14:11
加载中...