管道--二分答案+check

这个二分答案最难的点就是check函数!!!!

#include
using namespace std;
#define N 100011
typedef long long ll;
typedef pair PII;
int n,l;
struct edge
{
	int l,s;
}a[100011];
bool cmp(struct edge a,struct edge b)
{
	return a.l=a[i].l+x-a[i].s) continue;
		if(pos>=a[i].l-x+a[i].s-1) 
		pos=a[i].l+x-a[i].s;
		if(pos>=l) return true;
	}
	return false;
}
int main()
{
    cin>>n>>l;
    for(int i=0;i>a[i].l>>a[i].s;
    	mi=min(a[i].s,mi);
	}
	sort(a,a+n,cmp);
	ll l=mi;
	ll r=1000000000;
	ll an;
	while(l<=r)
	{
		ll m=(l+r)/2;
		if(check(m))
		{
			an=m;
			r=m-1;
		}else l=m+1;
	}
	cout<

你可能感兴趣的:(算法,数据结构)