文件目录

#include <bits/stdc++.h>
using namespace std;
int main()
{
    priority_queue<int> pf;
    int n, m, a, b, c, f;
    cin >> n >> m;
    while (n--)
    {
        cin >> a >> b >> c;
        for (int x = 1; x <= m; x++)
        {
            f = a * x * x + b * x + c;
            if (pf.size() == m)
            {
                if (pf.top() > f)
                {
                    pf.push(f);
                    pf.pop();
                }
                else
                    break;
            }
            else
                pf.push(f);
        }
    }
    stack<int> s;
    while (!pf.empty())
    {
        s.push(pf.top());
        pf.pop();
    }
    while (!s.empty())
    {
        cout << s.top() << " ";
        s.pop();
    }
    return 0;
}