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

Background \text{Background} 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.} 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.} 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.} 3. That Github Medal still have NOT got to my pocket yet.

Descrption \text{Descrption} 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} Given m quadratic function, their decision space is [1,100]. Please compute
the mininum  m  function values. \text{the mininum }m\text{ function values.} the mininum m function values.

Solution \text{Solution} Solution

Use  \text{Use } Use priority_queue  to solve this problem. \text{ to solve this problem.}  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();
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值