Mad Cow (two points)

Source: Internet
Author: User

Mad cow time limit: ms | Memory limit:65535 KB Difficulty:4
Describe
The farmer John built a long corral that consisted of N (2 <= n <= 100,000) compartments, numbered X1,..., XN (0 <= XI <= 1,000,000,000).
However, John's C (2 <= C <= N) Cows do not like this layout, and a few cows in a compartment, they will be fighting. In order not to let the cows hurt each other. John decided to allocate a compartment for the cows so that the minimum distance between any two cows is as large as possible, so what is the maximum minimum distance?
Input
There are multiple sets of test data, ending with EOF. First line: space-delimited two integers n and c second row-line n+1: The position of Xi is indicated separately
Output
each set of test data outputs an integer that satisfies the maximum minimum value of the test instructions and takes note of the newline.
Sample input
5 312849
Sample output
3
Exercises
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6 using namespacestd;7typedefLong LongLL;8 Const intmaxn=1e5+ -;9 intM[MAXN];Ten intn,c; One BOOLjsintx) { A     intt=m[0]; -     intCnt=0; -      for(intI=1; i<n;i++){ the         if(m[i]-t>=x) cnt++,t=M[i]; -     } -     if(CNT&GT;=C)return true; -     Else return false; + } - intErfen (intLintR) { +     intmid; A      while(l<=R) { atMid= (L+R)/2; -         if(JS (mid)) r=mid-1; -         ElseL=mid+1; -     } -     returnl; - } in intMain () { -      while(~SCANF ("%d%d",&n,&C)) { to          for(intI=0; i<n;i++) scanf ("%d", m+i); +Sort (m,m+N); -printf"%d\n", Erfen (0, m[n-1]-m[0])); the     } *     return 0; $}

Mad Cow (two points)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.