听灌多,求助
  • 板块灌水区
  • 楼主Michael1234
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/7/17 10:11
  • 上次更新2024/7/17 11:12:17
查看原帖
听灌多,求助
1161520
Michael1234楼主2024/7/17 10:11

交CF题出现了这个故障:

Probably, the solution is executed with error 'shift too large' on the line 26

有没有大佬帮忙看看 CF343C

代码:

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+5;
int n,m,ans,l=0,r=1e10,p[N],h[N];
inline bool check(int t)
{
	int x=1;
	for(int i=1;i<=n;i++)
	{
		if(h[i]<p[x])
		{
			while(x<=m&&p[x]-h[i]<=t)
			{
				x++;
			}
		}
		else
		{
			if(h[i]-p[x]>t)
			{
				return false;
			}
			int dis=h[i]-p[x];
			while(x<=m&&(p[x]-h[i]<=t-(dis<<1)||(p[x]-h[i])<<1+dis<=t))
			{
				x++;
			}
		}
		if(x>m)
		{
			return true;
		}
	}
	return false;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	for(int i=1;i<=m;i++)
	{
		cin>>p[i];
	}
	while(l<=r)
	{
		int mid=l+r>>1;
		if(check(mid))
		{
			r=mid-1;
			ans=mid;
		}
		else
		{
			l=mid+1;
		}
	}
	cout<<ans;
	exit(0); 
}
2024/7/17 10:11
加载中...