首页 > 广联达笔试
头像
Chauncey_Wu
编辑于 2020-07-29 19:16
+ 关注

广联达笔试

大佬们帮忙看看我今天广联达笔试第一道题有什么问题
vs上没问题  提交时编译不过
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main() {
	int n, m, x;   // m 次数   x高度
	cin >> n >> m >> x;
	if (n == 1) {
		cout << m * x << endl;
		return 0;
	}
	auto p = [](pair<int, int>a, pair<int, int>b) {return a.first > b.first; };
	priority_queue<pair<int, int>, vector<pair<int, int>>, decltype(p) > height(p);
	int h;
	while (n--) {
		cin >> h;
		height.push(make_pair(h, 0));
	}
	int t = height.top().first;
	height.pop();
	height.push(make_pair(t, -1));
	while (m--) {
		int temp1 = height.top().first, temp2 = height.top().second;
		height.pop();
		height.push(make_pair(temp1 + x, temp2));
	}
	int res = 0;
	while (height.top().second == 0) {
		height.pop();
	}
	res = height.top().first;
	cout << res << endl;;

	system("pause");
	return 0;
}


全部评论

(2) 回帖
加载中...
话题 回帖

相关热帖

近期热帖

历年真题 真题热练榜 24小时
技术(软件)/信息技术类
查看全部

近期精华帖

热门推荐