就离谱
查看原帖
就离谱
496009
黄舀啊楼主2021/10/11 20:32

我在dev-5.11本地运行样例一直不对,而且逻辑也查不出什么错误,最后心态炸了干脆直接提交洛谷了结果AC了就离谱

#include<iostream>
#include<cstdio>
using namespace std;
int p[100000],t[100000],use[100000];
int main(){
	int n,x,ans=0,start=1,top=0,temp1,temp2;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(x==0){
			cin>>p[++top]>>t[top];
			ans+=p[top];
		}
		else{
			cin>>temp1>>temp2;
			for(int j=start;j<=top;j++){
				if(temp2-t[j]>45) start++;
				else if(temp2-t[j]<=45&&p[j]>=temp1&&use[j]!=1){
					temp1=0;
					use[j]=1;
					break;
				}
			}
			ans+=temp1;
		}
	}
	cout<<ans;
	return 0;
}

然后在本地发现了一件有趣的事情 我把第12行的cin分开写了一下结果发现本地对了请问这是什么原理

2021/10/11 20:32
加载中...