The Mininum Function Value (luoguP2085 最小函数值)

Background\text{Background}

1. CSDN’s been upgraded today. There’s one MORE ad for each passage.\text{1. CSDN's been upgraded today. There's one MORE ad for each passage.}
2. Jane Zhang’s released her new Album on Apr 27th.\text{2. Jane Zhang's released her new Album on Apr 27th.}
3. That Github Medal still have NOT got to my pocket yet.\text{3. That Github Medal still have NOT got to my pocket yet.}

Descrption\text{Descrption}

Given m quadratic function, their decision space is [1,100]. Please compute\text{Given }m\text{ quadratic function, their decision space is [1,100]. Please compute}
the mininum m function values.\text{the mininum }m\text{ function values.}

Solution\text{Solution}

Use \text{Use }priority_queue to solve this problem.\text{ to solve this problem.}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>

using namespace std;
#define reg register
typedef long long ll;

int n,m;
int a[10010],b[10010],c[10010];
priority_queue<ll> q;

int main(){
	scanf("%d%d",&n,&m);
	for(reg int i=1;i<=n;++i){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		for(reg int j=1;j<=100;++j)
			q.push(-((ll)a[i]*j*j+b[i]*j+c[i]));
	}
	for(reg int i=1;i<=m;++i){
		printf("%lld ",-q.top());
		q.pop();
	}
}
posted @ 2019-04-29 14:40  TeacherDai  阅读(137)  评论(0)    收藏  举报