题意略。

思路:

容易知道那a次倍增放在同一个怪身上是最优的,其余的怪我们只需要取hp值和damage值中间最大的那个就好了(在b值的限制下)。

然而我们并不知道把那a次倍增放在哪个怪身上最好,那么我们就只能一只一只地试。

#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
typedef long long LL; struct node{
LL hp,dmg;
node(LL a = ,LL b = ){
hp = a,dmg = b;
}
}; LL pwr2[];
node store[maxn];
int n,a,b; bool cmp(const node& nd1,const node& nd2){
return (nd1.hp - nd1.dmg) > (nd2.hp - nd2.dmg);
} int main(){
scanf("%d%d%d",&n,&a,&b);
for(int i = ;i < n;++i) scanf("%lld%lld",&store[i].hp,&store[i].dmg);
sort(store,store + n,cmp);
LL sum = ;
for(int i = ;i < n;++i){
if(i < b) sum += max(store[i].dmg,store[i].hp);
else sum += store[i].dmg;
}
LL ans = sum;
for(int i = ;i < b;++i){
LL tmp = sum;
tmp -= max(store[i].dmg,store[i].hp);
tmp += max(store[i].hp<<a,store[i].dmg);
ans = max(ans,tmp);
}
if(b > ){
sum -= max(store[b - ].dmg,store[b - ].hp);
sum += store[b - ].dmg;
for(int i = b;i < n;++i){
LL tmp = sum;
tmp -= store[i].dmg;
tmp += max(store[i].hp<<a,store[i].dmg);
ans = max(ans,tmp);
}
}
printf("%lld\n",ans);
return ;
}

Codeforces 976E的更多相关文章

  1. Educational Codeforces Round 43 E&976E. Well played! 贪心

    传送门:http://codeforces.com/contest/976/problem/E 参考:https://www.cnblogs.com/void-f/p/8978658.html 题意: ...

  2. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  5. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  6. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  7. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  8. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  9. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

随机推荐

  1. php curl问题汇总

    0. curl是个什么东西 复制代码代码如下: PHP supports libcurl, a library created by Daniel Stenberg, that allows you ...

  2. Go语言圣经习题练习_1.5. 获取URL

    练习 1.7: 函数调用io.Copy(dst, src)会从src中读取内容,并将读到的结果写入到dst中,使用这个函数替代掉例子中的ioutil.ReadAll来拷贝响应结构体到os.Stdout ...

  3. TIJ读书笔记-第21章-并发

    一本Think in java,从去年6月份开始读,读了快一年了,也快读完了,然而回头想想,却好像什么也不记得了,好记性不如烂笔头,那就从现在开始记录一下吧.由于现在在读的是并发,那就先从这章开始吧. ...

  4. Linux基本操作及安装(部分)

    1.分别用cat \tac\nl三个命令查看文件/etc/ssh/sshd_config文件中的内容,   并用自己的话总计出这三个文档操作命令的不同之处? [root@localhost ~]# c ...

  5. 【eclipse】No enclosing instance of type A is accessible. Must qualify the allocation with an enclosing instance of type A

    用 eclipse 写 Java 代码时出现了这个问题,详细如下: No enclosing instance of type TestParsingLinkedList is accessible. ...

  6. Loadrunner参数(摘)

    一.占有率分析 1. 平均事务响应时间 Average Transaction Response Time 优秀:<2s 良好:2-5s 及格:6-10s 不及格:>10s 2. 每秒点击 ...

  7. 论文阅读 | Falcon: Balancing Interactive Latency and Resolution Sensitivity for Scalable Linked Visualizations

    作者: Dominik Moritz, Bill Howe, Jeffrey Heer 发表于CHI 2019, 三位作者都来自于University of Washington Interactiv ...

  8. MyISAM和InnoDB在索引上的差别及其它区别

    首先我们知道MyISM和InnoDB索引都是由B+树实现的,但在索引管理数据方式上却有所不同. InnoDB是聚集索引,数据文件是和(主键)索引绑在一起的,即索引 + 数据 = 整个表数据文件,通过主 ...

  9. Re-Architecting the Video Gatekeeper(一)

    原文 https://medium.com/netflix-techblog/re-architecting-the-video-gatekeeper-f7b0ac2f6b00 本文介绍了了内容配置工 ...

  10. DT-06 For MQTT

    感谢关注深圳四博智联科技有限公司产品!我公司提供完整的WiFi信号强度采集方案,包括WiFi信号采集.设备远程管理平台.智能终端应用等. Doit_MQTT透传固件基于乐鑫ESP_IOT_SDK使用C ...