1 条题解

  • 0
    @ 2025-11-30 16:28:06

    C++ :

    #include<cstdio>
    #include<queue>
    using namespace std;
    struct func
    {
        int num,value;
        func():num(0),value(0){}
        func(const int&_num,const int&_value):num(_num),value(_value){}
    };
    bool operator<(const func&A,const func&B)
    {
        return A.value>B.value;
    }
    priority_queue<func> heap;
    typedef int arr[10001];
    arr a,b,c,r;
    int f(const int&i,const int&x)
    {
        return a[i]*x*x+b[i]*x+c[i];
    }
    int n,m;
    func y;
    int main()
    {
        int t;
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;++i)
        {
            scanf("%d%d%d",&a[i],&b[i],&c[i]);
            heap.push(func(i,f(i,r[i]=1)));
        }
        for(int i=1;i<=m;++i)
        {
            y=heap.top();
            heap.pop();
            printf("%d",y.value);
            if(i<m)printf(" ");else printf("\n");
            heap.push(func(y.num,f(y.num,++r[y.num])));
        }
        return 0;
    }
    
    • 1

    信息

    ID
    1438
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者