感觉没什么问题,可就对了两个,求热心大佬解答
查看原帖
感觉没什么问题,可就对了两个,求热心大佬解答
1189413
PURE_LOVE楼主2025/1/14 17:45
#include<bits/stdc++.h>
using namespace std;
int n, a, b;
priority_queue<int>brr;
vector<int>arr;
void hanshu()
{
	int temp, tp;
	while (b--)
	{
		temp = brr.top();
		tp = temp / 2;
		temp = temp - tp;
		brr.pop();
		brr.push(tp);
		brr.push(temp);
	}
}
int main()
{
	cin >> n >> a >> b;
	int temp;
	int x = a;	
	while (x--)
	{
		cin >> temp;
		arr.push_back(temp);
	}
	if(arr[0])brr.push(arr[0]);
	for (int i = 1; i < a ;i++)
	{
		temp = arr[i] - arr[i - 1];
		brr.push(temp);
	}
	if (arr[a-1]!=n)brr.push(n - arr[a - 1]);
	hanshu();
	cout << brr.top();
}
2025/1/14 17:45
加载中...