链接:Miku
----------------------------------
显然在x>0的时候,函数都是随x增大而增大的
所以说嘛,优先队列就能搞出来
------------------------------------
#include<iostream> #include<cstdio> #include<algorithm> #include<queue> using namespace std; int n,m; int a[10001],b[10001],c[10001]; struct need{ int x; int i; int v; friend bool operator < (need a,need b){ return a.v>b.v; } } now,x; priority_queue <need>q ; int main(){ cin>>n>>m; for(int i=1;i<=n;++i){ scanf("%d%d%d",&a[i],&b[i],&c[i]); now.x=1; now.i=i; now.v=a[i]+b[i]+c[i]; q.push(now); } for(int i=1;i<=m;++i){ x=q.top(); q.pop(); cout<<x.v<<" "; now.i=x.i; now.x=x.x+1; now.v=a[now.i]*now.x*now.x+now.x*b[now.i]+c[now.i]; q.push(now); } return 0; }