当前位置:网站首页>D - function (HDU - 6546) girls' competition
D - function (HDU - 6546) girls' competition
2022-07-06 16:03:00 【It's Xiao Zhang, 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; // Mark x Increase of one function at a time 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;// Custom priority queue ;
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; // When x Equal to a moment ;
t.x=1;
t.mark=t.a*(2*t.x+1)+t.b; //f(x+1)-f(x), Growth ;
pq.push(t); // Push the ;
}
for(int i=0;i<m-n;i++){
node temp=pq.top();
// Increase every time 1 Least function , have to x Value , And then again temp.x++;
pq.pop();
temp.x++;
temp.mark=temp.a*(2*temp.x+1)+temp.b;// growth f(x+1)-f(x);
pq.push(temp);
ans+=temp.a*(2*temp.x-1)+temp.b;
//ans yes f(x-1) Value , So subtract the amount of growth ;
}
printf("%lld\n",ans);
}
return 0;
}
边栏推荐
- 渗透测试 ( 8 ) --- Burp Suite Pro 官方文档
- Opencv learning log 15 count the number of solder joints and output
- MySQL import database error [err] 1273 - unknown collation: 'utf8mb4_ 0900_ ai_ ci’
- Determine the Photo Position
- mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’
- Information security - Epic vulnerability log4j vulnerability mechanism and preventive measures
- Penetration test (4) -- detailed explanation of meterpreter command
- Perform general operations on iptables
- 信息安全-威胁检测-NAT日志接入威胁检测平台详细设计
- Cost accounting [21]
猜你喜欢

Gartner: five suggestions on best practices for zero trust network access

1010 things that college students majoring in it must do before graduation

入门C语言基础问答

Penetration test (8) -- official document of burp Suite Pro
![MySQL import database error [err] 1273 - unknown collation: 'utf8mb4_ 0900_ ai_ ci’](/img/e6/f4a696179282fe1f4193410c5a493a.png)
MySQL import database error [err] 1273 - unknown collation: 'utf8mb4_ 0900_ ai_ ci’

渗透测试 ( 5 ) --- 扫描之王 nmap、渗透测试工具实战技巧合集

【高老师软件需求分析】20级云班课习题答案合集

基于web的照片数码冲印网站

程序员的你,有哪些炫技的代码写法?

信息安全-安全编排自动化与响应 (SOAR) 技术解析
随机推荐
Research Report of cylindrical grinder industry - market status analysis and development prospect forecast
Accounting regulations and professional ethics [1]
Frida hook so layer, protobuf data analysis
Opencv learning log 13 corrosion, expansion, opening and closing operations
China potato slicer market trend report, technical dynamic innovation and market forecast
1010 things that college students majoring in it must do before graduation
[exercise-2] (UVA 712) s-trees
渗透测试 ( 4 ) --- Meterpreter 命令详解
0-1 knapsack problem (I)
想应聘程序员,您的简历就该这样写【精华总结】
Borg Maze (BFS+最小生成树)(解题报告)
Opencv learning log 19 skin grinding
Ball Dropping
China's earthwork equipment market trend report, technical dynamic innovation and market forecast
X-Forwarded-For详解、如何获取到客户端IP
【练习-8】(Uva 246)10-20-30==模拟
【练习-7】Crossword Answers
【高老师软件需求分析】20级云班课习题答案合集
nodejs爬虫
CEP used by Flink