本地样例能过,提交全部RE咋办
查看原帖
本地样例能过,提交全部RE咋办
559037
ListentoRain楼主2023/2/12 15:26

求助
RE信息:Runtime Error. Received signal 11: Segmentation fault with invalid memory reference.

#include<iostream>
using namespace std;
int n,head,tail,sum,mo,ti;
bool type;
struct coupon{
	int time,money;
}cp[100009];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>type;
		if(!type){
			cin>>cp[head].money>>cp[head].time;
			sum+=cp[head].money;
			head++;
			continue;
		}else{
			cin>>mo>>ti;
			s:
			if(ti-cp[tail].time>45){
				tail++;
				goto s;
			}
			if(ti-cp[tail].time<=45 and tail!=head and cp[tail].money<=mo){
				tail++;
				continue;
			}
			sum+=mo;
		}
	}
	cout<<sum;
}
2023/2/12 15:26
加载中...