Codeforces 976E
题意略。
思路:
容易知道那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的更多相关文章
- Educational Codeforces Round 43 E&976E. Well played! 贪心
传送门:http://codeforces.com/contest/976/problem/E 参考:https://www.cnblogs.com/void-f/p/8978658.html 题意: ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
随机推荐
- .net持续集成sonarqube篇之项目管理与用户管理
系列目录 删除项目 在学习阶段,我们可能需要经常删除已构建的项目,在sonarqube中想要删除一个项目有两个入口,都在Administration导航栏内. 在项目内部的管理界面删除 如果项目处于打 ...
- Jsp机试题 (用户登录用户注册/用户注销功能)
1. 用户登录 实现用户登录,功能,三个页面登录页面login.jsp,登录逻辑处理页面loginSubmit.jsp,欢迎页面welcome.jsp.用户再登录页面输入用户名和密码,前台页面使用js ...
- tp3 的前端内置标签
Volist 标签 volist标签通常用于查询数据集(select 方法),对于查询出来的结果数组进行遍历输出. 首先赋值: $User = M("User"); $list = ...
- Spring WebClient vs. RestTemplate
1. 简介 本教程中,我们将对比 Spring 的两种 Web 客户端实现 -- RestTemplate 和 Spring 5 中全新的 Reactive 替代方案 WebClient. 2. 阻塞 ...
- 【iOS】判断苹果的设备是哪种
有时候需要判断苹果的设备是 iPhone 还是 iPad 等其他设备,示例代码如下: if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUs ...
- 【iOS】Apple Mach-O Linker Error Linker command failed with exit code 1
又遇到了这个问题,貌似之前遇到过……如图所示: 解决方法寻找中………… 在 Stack Overflow 找到了解决方法,如下: 参考链接:Apple Mach-O Linker Error
- gulp压缩js文件报错日志
输出 gulp-uglify 压缩js文件时报错信息 gulp.task('es6', function () { return gulp.src('src/main/webapp/bower_com ...
- JVM实战---类加载的过程
任何程序都需要加载到内存才能与CPU进行交流 同理, 字节码.class文件同样需要加载到内存中,才可以实例化类 ClassLoader的使命就是提前加载.class 类文件到内存中 在加载类时,使用 ...
- postman->newman->jenkins构建过程的问题记录及解决方法
从postman导出请求集合后要做的工作: 需要调整导出的json文件,如配置环境变量{{host}},需要修改成准确的url; 通过newman执行newman run test_request.j ...
- 解读 PHP 的 P++提案
解读 PHP 的 P++提案 周末看到一篇文章说 PHP 创始人提议将 PHP 拉出新分支,创建 P++ 语言.随后阅读了一下 Zeev Suraski 发起的这个邮件列表,大致了解了一下,这里做个解 ...