出什么问题了吗
查看原帖
出什么问题了吗
269403
天宇1105楼主2020/7/14 18:41
#include <bits/stdc++.h>
using namespace std;
struct ticket {
	int price;
	int time;
	bool u;
} a[10000];
int main() {
	int n,use=0,h=0,d=0;
	int by;
	int p,t;
	cin>>n;
	for (int i = 0; i < n; ++i) {
		cin>>by>>p>>t;
		if (by) {
			while(1) {
				if (a[d].price>=p && a[d].u==1 && (t-a[d].time)) {
					a[d].u=0;
					d=0;
					break;
				}
				if (d>=h) {
					d=0;
					use+=p;
					break;
				}
				d++;
			}
		} else {
			use+=p;
			a[h].time=t;
			a[h].u=1;
			h++;
		}
	}
	cout<<use;
	return 0;
}
2020/7/14 18:41
加载中...