POJ 1852 Ants

Source: Internet
Author: User

1#include <iostream>2#include <cstdio>3#include <algorithm>4#include <cstring>5 #defineSC (x) scanf ("%d",& (x))6 #defineSC2 (x, y) scanf ("%d%d", & (×), & (Y))7 #definePF (x) printf ("%d\n", X)8 #definePF2 (x, y) printf ("%d%d\n", X, y)9 #definefor (I,b,e) for (i=b; i<=e; i++)Ten #defineCL (x, y) memset (x,y,sizeof (×)) One Const intMAX =1000000; A intAnt[max], Min[max]; - using namespacestd; - intMainintargcChar*argv[]) { the     intT, L, N, I, K, Max; - SC (T); -      while(t--){ -Max =0; K =0; +CL (Min,0); - SC2 (L, n); +for (I,0, N-1) SC (ant[i]); ASort (ant, ant+n); atmax = ant[n-1] > (l-ant[0]) ? ant[n-1]: (l-ant[0]); -for (I,0, N-1){ -             if(Ant[i] <= L/2){ -min[k++] =Ant[i]; -             } -             Else{ inmin[k++] = LAnt[i]; -             } to         } +Sort (Min, min+k); -PF2 (min[k-1], max);  the     }     *     return 0; $}
View Code
/* 1. Fastest: Find the closest point to the middle, and the time it takes to get to the nearest endpoint is the time for all the ants to fall 2. Slowest: For each point, find out that the farthest distance to the two endpoints is the time that  all the ants fall  .

POJ 1852 Ants

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.