求助!!急
查看原帖
求助!!急
158803
hierophant_green楼主2021/10/1 22:32
#include<bits/stdc++.h>
using namespace std;
struct node{
	bool yesorno = 1;
	int sorb, price, time;
};
node a[10005];
int n, ans;
int main(){
	int time, price, sorb;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i].sorb >> a[i].price >> a[i].time;
	for(int i = 1; i <= n; i++){
		if(a[i].yesorno == 1)
			ans += a[i].price;
		if(a[i].sorb == 0){
			for(int j = i + 1; j <= n; j++){
				if(a[j].time - a[i].time > 45)
					break;
				if(a[j].sorb == 1 && a[j].yesorno == 1){
					if(a[j].time - a[i].time <= 45 && a[j].price <= a[i].price){
						a[j].yesorno = 0;
						break;
					}
				}
			}
		}
	}
	cout << ans;
	return 0;
}

蒟蒻求助,为什么只有三十?还能怎么优化啊

2021/10/1 22:32
加载中...