auto check=[&](int x) { int tk=k; int curR=a[0].r; tk--; for(int i=1;i<n;i++) { if(a[i].l-curR>=x) { curR=a[i].r; tk--; } if(tk<=0)return1; } return0; };
int l=0,r=1e9; while(l<r) { int mid=(l+r+1)>>1; if(check(mid)) { l=mid; } else { r=mid-1; } } if(l==0)l=-1; cout<<l; }
补题
E
Problem Statement
The country of AtCoder has N cities and M roads. The i-th road (1≤i≤M) connects cities ui and vi bidirectionally, and allows travel from one to the other in Ti minutes.
Additionally, each city has a warp gate installed, and you can travel from city i(1≤i≤N) to city j(1≤j≤N) using the warp gate in Xi+Xj+Y minutes.
There are no other ways to travel between cities in the country.
For each k=2,3,…,N, solve the following problem:
Find the minimum time required to travel from city 1 to city k.
The time required to transfer from a road or warp gate to another road or warp gate at the same city is negligible.