10 pts求调
查看原帖
10 pts求调
843733
cubehead楼主2023/12/19 21:13
#include <bits/stdc++.h>

using namespace std;

int n, m;
struct Node {
	int x, a, b, c, ans;
	bool operator < (const Node &W) const {
		return ans > W.ans;
	}
};

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	priority_queue<Node> q;
	for (int i = 1; i <= n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		q.push({1, a, b, c, a * 1 + b + c});
	}
	for (int i = 1; i <= m; i++) {
		auto [a, b, c, d, e] = q.top();
		cout << e << '\n';
		q.pop();
		q.push({a + 1, b, c, d, b * (a + 1) * (a + 1) + c * (a + 1) + d});
	}
	return 0;
}
2023/12/19 21:13
加载中...