当前位置:网站首页>D - Function(HDU - 6546)女生赛
D - Function(HDU - 6546)女生赛
2022-07-06 09:25:00 【是小张张呀 zsy】
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
struct node
{
ll a,b,c;
ll mark; //标记x每次加一函数的增长f(x+1)-f(x);
ll x;
bool operator<(const node &t) const{
return mark > t.mark;
}
};
int main()
{
ll n,m;
while(~scanf("%lld%lld",&n,&m))
{
priority_queue<node> pq;//自定义的优先队列;
ll ans=0;
for(int i=0;i<n;i++){
node t;
scanf("%lld%lld%lld",&t.a,&t.b,&t.c);
ans+=t.a+t.b+t.c; //当x等于一时;
t.x=1;
t.mark=t.a*(2*t.x+1)+t.b; //f(x+1)-f(x),增长量;
pq.push(t); //压入;
}
for(int i=0;i<m-n;i++){
node temp=pq.top();
//每次取增长1最少的函数,得x的值,然后再 temp.x++;
pq.pop();
temp.x++;
temp.mark=temp.a*(2*temp.x+1)+temp.b;//增长f(x+1)-f(x);
pq.push(temp);
ans+=temp.a*(2*temp.x-1)+temp.b;
//ans是f(x-1)的值,所以减去增长的量;
}
printf("%lld\n",ans);
}
return 0;
}
边栏推荐
- Learning record: STM32F103 clock system overview working principle
- 编程到底难在哪里?
- Market trend report, technical innovation and market forecast of Chinese hospital respiratory humidification equipment
- Future trend and planning of software testing industry
- STM32学习记录:玩转按键控制蜂鸣器和LED
- FSM and I2C experiment report
- csapp shell lab
- LeetCode#118. Yanghui triangle
- Interview answering skills for software testing
- China's salt water membrane market trend report, technological innovation and market forecast
猜你喜欢
ucore lab 2
Want to change jobs? Do you know the seven skills you need to master in the interview software test
Es6---es6 content details
ucorelab4
csapp shell lab
Future trend and planning of software testing industry
Matlab example: two expressions of step function
UCORE LaB6 scheduler experiment report
学习记录:串口通信和遇到的错误解决方法
FSM和i2c实验报告
随机推荐
JS --- JS function and scope (II)
STM32学习记录:玩转按键控制蜂鸣器和LED
C 基本语法
Stm32 dossiers d'apprentissage: saisie des applications
0-1背包問題(一)
Cost accounting [17]
China's earthwork equipment market trend report, technical dynamic innovation and market forecast
LeetCode#198. raid homes and plunder houses
Future trend and planning of software testing industry
Crawling cat's eye movie review, data visualization analysis source code operation instructions
C4D quick start tutorial - creating models
STM32学习记录:输入捕获应用
动态规划前路径问题
What are the commonly used SQL statements in software testing?
csapp shell lab
Word macro operation: convert the automatic number in the document into editable text type
JS --- detailed explanation of JS DOM (IV)
JS --- all basic knowledge of JS (I)
学习记录:STM32F103 时钟系统概述工作原理
How to build a nail robot that can automatically reply