您的位置:首页 > 理论基础 > 计算机网络

武汉科技大学网络赛1578: LAMP

2016-04-18 20:48 387 查看


1578: LAMP

Time Limit: 1 Sec Memory Limit: 128 MB
64bit IO Format: %lld

Submitted: 12 Accepted: 6

[Submit][Status][Web
Board]


Description

Pang Pang is absored in Linux now, he enjoys using LAMP(Linux + Apache + MySQL + php), and runs a great blog on it! One day, the chief of the Pang Pang's hometown found him by his homepage, and send a email to him.

The chief asked him to solve the problem of lamp(not LAMP): The main road of the country has a lot of street lamps, which make the road beautiful at night. But at the same time, the cheif noticed that the light of the lamp overlap at many places, which will
cost lots of electricity. However when the chief tried to turn down the lamps, some place were not lit. So he asked Pang to alter the brightness of all the lamps, to make sure that everywhere of the street could be lit up, and minimize the distance of each
lamp could light up.


Input

Multiply test cases, terminate with EOF. The descriptions of the test cases follow:

The first line of each test case contains integers N and M (0 < N < 10000 < M < 32768). We assume that the length of the main road is M meters, starts from point 0 and ends at point M. There are N lamps on the road.

The following line contains N integers seperated by single space - the distance between the start point and the i-th street lamp.


Output

For each test case, output one line with a single real number, rounded to two decimal places.


Sample Input


7 15
14 5 2 7 9 14 1
5 20
1 7 12 18 4



Sample Output

2.50
3.00


//贪心就行,只不过要注意路灯到最左最右边的距离
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
const int maxn = 10005;
using namespace std;

int lamp[maxn];

int main()
{
int n,m;
while(scanf("%d %d", &n, &m) != EOF)
{
for(int i = 0; i < n; i++)
scanf("%d",&lamp[i]);
sort(lamp, lamp+n);
double ans = (double)max(lamp[0], m - lamp[n-1]);
for(int i = 1; i < n; i++)
ans = max(ans, (double)(lamp[i]-lamp[i-1])/2);
printf("%.2lf\n",ans);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: