题目大意:
给你n个牛舍,把c只牛放在牛舍里,要求最近的两头牛之间距离最大。
思路:
直接二分,枚举答案ans,如果满足,则搜索更大的。。
#include#include #include using namespace std; const int MAXN= 100000+10; int a[MAXN],n,c; bool ok(int dis) { int last=0; for(int i=1;i =n) return false; last=next; } return true; } int main() { while(~scanf(%d%d,&n,&c)) { for(int i=0;i >1); if(ok(mid)) L=mid; else R=mid; } printf(%d ,L); } return 0; }