比赛 ?板子大赛 评测结果 AAAEEETEEE
题目名称 最小函数值 最终得分 30
用户昵称 王潇翊 运行时间 2.875 s
代码语言 C++ 内存使用 6.10 MiB
提交时间 2026-01-17 09:37:54
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
long long n,m,a[N],cnt = 1;
int main()
{
    freopen("minval.in","r",stdin);
    freopen("minval.out","w",stdout);
    cin >> n >> m;
    for (int i = 1,x,y,z;i <= n;i++)
    {
        cnt = (cnt > m + 1 ? m + 1 : cnt);
        cin >> x >> y >> z;
        int s = 1;
        while (a[m] > s * s * x + s * y + z || cnt <= m)
        {
            a[cnt] = s * s * x + s * y + z;
            cnt++;
            s++;
        }
        sort (a + 1,a + cnt);
    }
    for (int i = 1;i <= m;i++)
    {
        cout << a[i] << " ";
    }
    return 0;
}