样例过了 但全是RE 求调!
查看原帖
样例过了 但全是RE 求调!
934455
20221113jmt楼主2023/8/29 08:53
#include<cstdio>
using namespace std;

struct jl{
	int orz,price,time;
}a[10010];

struct pj{
	int price,time;
}b[10010];

int front = 0, rear = -1;

int main(){
	int n, ans;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int o,p,t;
		scanf("%d%d%d",&o,&p,&t);
		a[i] = {o,p,t};
	}
	for(int i=1;i<=n;i++){
		if(a[i].orz == 0){
			b[++rear] = {a[i].price, a[i].time};
			ans += a[i].price;
		}else{
			int time = a[i].time, price = a[i].price;
			while(b[front].time + 45 < time) front++;
			bool flag = false;
			for(int j=front;j<=rear;j++){
				if(b[j].price >= price){
					for(int k=j;k<=rear;k++) b[k] = b[k+1];
					rear--;
					flag = true;
					break;
				}
			}
			if(!flag) ans += price;
		}
	}
	printf("%d\n",ans);
	return 0;
}
2023/8/29 08:53
加载中...