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个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
随机推荐
- python初步编写用户登录
python初步编写用户登录 python编写用户登录 用python写一个脚本,使得这个脚本在执行后,可以产生如下的效果: 1.用户的账号为:root 密码为:westos 2.用户账号和密码均输 ...
- Mysql处理中文乱码的问题
一开始在创建完毕数据库和数据表之后,插入中文发现在mysql命令行和在sqlyog终端上看都是乱码,查看了一些文章,写的内容都一样,无非是如下几个步骤: 1:修改数据库字符集为utf8 2:修改数据表 ...
- JAVA 基于TCP协议的一对一,一对多文件传输实现
最近老师给我们上了多线程和TCP和UDP协议,其中一个要求就是我们用JAVA协议一个基于TCP和UDP这两种协议的一对一文件上传和一对多文件上传. 然后我就开始分析TCP和UDP这两个协议的特点,发现 ...
- HZOJ 单
两个子任务真的是坑……考试的时候想到了60分的算法,然而只拿到了20分(各种沙雕错,没救了……). 算法1: 对于测试点1,直接n遍dfs即可求出答案,复杂度O(n^2),然而还是有好多同学跑LCA/ ...
- vue使用video.js解决m3u8视频播放格式
今天被这个关于m3u8视频播放不了搞了一下午,这个项目所有的视频流都是m3u8格式的,后台给我们返回的都是m3u8格式的视频流,解决了好长时间,看了好多博客,只有这个博客给我点启发,去解决这个问题,请 ...
- centos7更新yum库为aliyun库
1. 备份原来的yum源$sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak 2.设置ali ...
- Find out "Who" and "Where"
Yesterday a friend of mine Kirby came to me with a smartphone and she wanted me to do her a favor. S ...
- ABP实现EF执行SQL(增删改查)解决方案
前言 一般情况下,使用EF中的语法可以帮助我们完成绝大部分业务,但是也有特殊的情况需要直接执行的Sql语句.比如,我们的业务过于复杂繁琐,或是有些业务使用EF操作时比较复杂,但是使用的Sql时会很简单 ...
- 【算法】【查找】二分法 Bisection
#include<stdio.h> int main(){ ,,,,,,,,,,,,,,}; ; //长度 ; //要查找到的值 int Bisection(int x,int* a,in ...
- javascript数组去重 js数组去重
数组去重的方法 一.利用ES6 Set去重(ES6中最常用) function unique (arr) { return Array.from(new Set(arr)) } var arr = [ ...