原题链接:

  http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1655

题意与思路:请看大神的吧!!!!-->链接:http://blog.csdn.net/shuangde800/article/details/7828705

      让我崩溃一下午的题,大神两句话解决!!!

本人代码(较low):

 1 #include<cstdio>
 2 #include<string>
 3 #include<cstring>
 4 #include<iostream>
 5 #include<algorithm>
 6 
 7 using namespace std;
 8 
 9 int a[1000001];
10 
11 int main()
12 {
13     int t,l,n;
14     int i;
15     cin>>t;
16     while(t--)
17     {
18         int max=0,min=0,midX=0;
19         double mid=0;
20         cin>>l>>n;
21         mid=l/2.0;
22         for(i=0;i<n;i++)
23             scanf("%d",&a[i]);
24         sort(a,a+n);
25         for(i=0;i<n;i++)
26         {
27             if(a[i]<mid)
28             {
29                 if(a[i]>min)
30                     min=a[i];
31             }
32             else if(a[i]==mid)
33             {
34                 min=a[i];
35                 break;
36             }
37             else
38             {
39                 if(l-a[i]>min)
40                 {
41                     min=l-a[i];
42                     break;
43                 }
44             }
45         }
46         max=(l-a[0])<a[n-1]?a[n-1]:(l-a[0]);
47         cout<<min<<' '<<max<<endl;
48     }
49     return 0;
50 }

------------------欢迎评论---------------------------