首页 > 其他分享 >路灯照明

路灯照明

时间:2022-09-30 13:44:05浏览次数:63  
标签:路灯 nums int maxValue vector 照明 include

路灯照明 [(https://www.online1987.com/路灯照明/)]

#include<iostream>
#include<climits>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int maxValue = 0;
	int n = 0;
	int l = 0;
	cin >> n >> l;
	vector<int> nums(n+1, 0);//vector只有初始化的元素可以赋值,如果vector不初始化,默认大小为0,对nums[i]赋值会报错.
	for (int i = 0; i<n&&cin >> nums[i]; ++i) {
		;
	}
	sort(nums.begin(), nums.end());
	for (int i = 0; i < n; ++i) {
		if (i == n - 1) maxValue = max(l - nums[i + 1], maxValue);
		maxValue = max(nums[i + 1] - nums[i], maxValue);
	}
	 cout<<(double)maxValue / 2<<endl;
	 return 0;
}

标签:路灯,nums,int,maxValue,vector,照明,include
From: https://www.cnblogs.com/chunbai11/p/16744658.html

相关文章

  • 高性价比蓝牙/2.4G芯片PHY6252在智慧照明应用
    在未来的很长一段时间内,智慧照明都将是整个物联网的重要发展领域。现在还只是智慧照明发展的初期,很多应用场景都还处在探索阶段,适应物联网时代需求的芯片必须是远高于目前......