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个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
随机推荐
- MyBatis-Plus 使用说明介绍
先看一下和MyBatis 不同点说明: @GetMapping("/select_sql") public Object getUserBySql() { User user=ne ...
- Linux操作系统和Windows操作系统的区别
1.免费与收费 在中国,windows和linux都是免费的,至少对个人用户是如此,如果那天国内windows真的严打盗版了,那linux的春天就到了!但现在linux依然是任重道远,前路漫漫. 2. ...
- python课堂整理18---文件操作(下)
一.b模式,字节方式(二进制的单位),rb wb ab f = open('test.py', 'rb', encoding = 'utf-8') 报错,因为用了b模式,就不能再指定编码格式了,已经指 ...
- 高级查询MYsql(二) 练习
一.单词部分 ①exist存在②temp临时的③district区域 ④content内容⑤temporary暂时的 二.预习部分 1.表连接都可以用子查询替换吗 是的 2.检测某列是否存在某个范围可 ...
- java oop 单列 双列 集合, 迭代器 的使用和说明
一.集合(Collection) (1)集合的由来? 我们学习的是Java -- 面向对象 -- 操作很多对象 -- 存储 -- 容器(数组和StringBuffer) -- 数组 而数组的长度固定, ...
- Git 学习笔记之(一) 使用 git gui 从github上下载代码
背景: 目前一些开源代码均在 GitHub上管理的,包括自己写的代码也可以放在上面进行管理.但问题是,当你换一台电脑,想要将你自己放在 GitHub 上的代码工程下载下来的时候,会遇到各种问题,目前可 ...
- 大数阶乘(c++实现)
#include <iostream>using namespace std;#define N 1000int BigNumFactorial(int Num[], int n);voi ...
- ORACLE 的CONNECT BY、START WITH,CONNECT_BY_ROOT、CONNECT_BY_ISLEAF、SYS_CONNECT_BY_PATH,LEVEL的使用(Hierarchical query-层次查询)
如果表中存在层次数据,则可以使用层次化查询子句查询出表中行记录之间的层次关系基本语法: START WITH <condition1> CONNECT BY [ NOCYCLE ] < ...
- WIZnet-io6Library下载及使用
概观 io6Library是一个IPv6集成库,可以轻松集成和管理使用WIZnet硬连线双TCP / IP堆栈控制器(WIZCHIP)产品系列的用户应用程序. io6Library用于管理依赖于用户特 ...
- 11、增强型for循环对二维数组的输出(test8.java)
由于笔者原因,这部分知识,尚不能整理出代码,笔者会好好学习增强型for循环中迭代起的相关知识,在笔者有能力,书写好这段代码后,将对本篇文章,进行二次修改,也同时欢迎大家与笔者交流,共同学习,共同进步. ...