本地样例过了,为什么提交上去CE啊。。。
查看原帖
本地样例过了,为什么提交上去CE啊。。。
253370
_Kelsey楼主2021/7/3 23:48
#include<iostream>
#include<cstdio>
using namespace std;

struct ticket{
	int z_prize,last_time,used;
}a[100010];

int top,end,cost,n;
	int prize,op,time;
	bool can = false;
	
int main(){
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		cin>>op>>prize>>time;
		if(op == 0){
			cost += prize;
			a[end].last_time = time + 45;
			a[end++].z_prize = prize;
		}
		else{
			while(top < end && a[top].last_time < time){
				top++;
			}
			for(int j = top;j < end;++j){
				if(a[j].z_prize >= prize && a[j].used == 0){
					can = true;
					a[j].used = 1;
					break;
				}
			}
			if(!can) cost += prize;
		}
	}
	printf("%d",cost);
	return 0;
}
2021/7/3 23:48
加载中...