ACM-ICPC Live Archive 6505---Metal (two minutes)

Source: Internet
Author: User

Actually, that OJ, I don't know what the name is.
This problem, you will know the answer to two points after reading
And then it becomes a matter of judgment, in fact, to group points
Assuming the answer now is cost, then if the vertical distance of 2 points >2*cost, then these 2 points cannot be divided into one group

/************************************************************************* > File Name:code.cpp > Author: ALex > Mail: [email protected] > Created time:2015 May 01 Friday 18:01 11 seconds *********************************** *************************************/#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <queue>#include <stack>#include <map>#include <bitset>#include <set>#include <vector>using namespace STD;Const DoublePI =ACOs(-1.0);Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-15;typedef Long LongLL;typedefPair <int,int> PLL;structPoint {intx, y;} point[10010];intCMP (point A, point B) {returna.x < b.x;}intMain () {intTscanf("%d", &t); while(t--) {intN, K;scanf("%d%d", &n, &k); for(inti =1; I <= N; ++i) {scanf("%d%d", &point[i].x, &AMP;POINT[I].Y); } sort (Point +1, point + N +1, CMP);DoubleL =0, R = (Double) INF, Mid;intUse =0;DoubleAns while(R-l >1e-6) {mid = (L + r)/2; Use =1;intmins = point[1].Y, Maxs = point[1].Y; for(inti =1; I <= N;                ++i) {mins = min (mins, point[i].y); MAXS = Max (Maxs, POINT[I].Y);if(Maxs-mins >2* mid) {++use;                    mins = POINT[I].Y;                Maxs = POINT[I].Y; }            }if(Use > K)            {L = mid; }Else{ans = mid;            R = Mid; }        }printf("%.1f\n", ans); }return 0;}

ACM-ICPC Live Archive 6505---Metal (two minutes)

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.