当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
Analyse du format protobuf du rideau en temps réel et du rideau historique de la station B
用C语言写网页游戏
C语言必背代码大全
程序员的你,有哪些炫技的代码写法?
【高老师UML软件建模基础】20级云班课习题答案合集
Penetration test (7) -- vulnerability scanning tool Nessus
mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’
Nodejs+vue online fresh flower shop sales information system express+mysql
[exercise-5] (UVA 839) not so mobile (balance)
Information security - threat detection - detailed design of NAT log access threat detection platform
随机推荐
[exercise -11] 4 values why sum is 0 (and 4 values of 0)
[exercise-2] (UVA 712) s-trees
[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class
B - 代码派对(女生赛)
渗透测试 ( 2 ) --- 渗透测试系统、靶机、GoogleHacking、kali工具
Perinatal Software Industry Research Report - market status analysis and development prospect forecast
[exercise -10] unread messages
Opencv learning log 14 - count the number of coins in the picture (regardless of overlap)
【练习-3】(Uva 442)Matrix Chain Multiplication(矩阵链乘)
C语言是低级和高级的分水岭
[exercise-3] (UVA 442) matrix chain multiplication
[exercise-1] (UVA 673) parentheses balance/ balanced brackets (stack)
渗透测试 ( 4 ) --- Meterpreter 命令详解
对iptables进行常规操作
渗透测试 ( 7 ) --- 漏洞扫描工具 Nessus
[exercise-8] (UVA 246) 10-20-30== simulation
C语言数组的概念
If you want to apply for a programmer, your resume should be written like this [essence summary]
[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class
Record of brushing questions with force deduction -- complete knapsack problem (I)