当前位置:网站首页>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;
}
边栏推荐
- What is "test paper test" in software testing requirements analysis
- Want to change jobs? Do you know the seven skills you need to master in the interview software test
- China chart recorder market trend report, technology dynamic innovation and market forecast
- ArrayList set
- Accounting regulations and professional ethics [1]
- ucore Lab 1 系统软件启动过程
- csapp shell lab
- 学习记录:TIM—基本定时器
- Future trend and planning of software testing industry
- Cost accounting [14]
猜你喜欢
Word macro operation: convert the automatic number in the document into editable text type
C4D quick start tutorial - creating models
学习记录:使用STM32F1看门狗
JS --- all basic knowledge of JS (I)
csapp shell lab
Learning record: use STM32 external input interrupt
力扣刷题记录
What to do when programmers don't modify bugs? I teach you
LeetCode#36. Effective Sudoku
ucore lab 2
随机推荐
程序员的你,有哪些炫技的代码写法?
Indonesian medical sensor Industry Research Report - market status analysis and development prospect forecast
STM32如何使用STLINK下载程序:点亮LED跑马灯(库版本)
Learning record: understand systick system timer and write delay function
Jupyter installation and use tutorial
Learning record: Tim - capacitive key detection
Learning record: STM32F103 clock system overview working principle
Research Report on market supply and demand and strategy of China's medical chair industry
编程到底难在哪里?
Perinatal Software Industry Research Report - market status analysis and development prospect forecast
Servlet
学习记录:使用STM32F1看门狗
ArrayList set
C语言必背代码大全
What are the commonly used SQL statements in software testing?
Research Report on market supply and demand and strategy of geosynthetics industry in China
FSM和i2c实验报告
Cost accounting [19]
12306: mom, don't worry about me getting the ticket any more (1)
What is "test paper test" in software testing requirements analysis