传送门:http://codeforces.com/contest/976/problem/E

参考:https://www.cnblogs.com/void-f/p/8978658.html

题意:

对于每一个生物,有一个ph值和伤害值。现在有a次使ph值乘2的机会,有b次是伤害值等于ph值得机会。

问最后能得到最大的伤害总和是多少。

思路:自己一开始也想的是贪心,但是贪的姿势不正确。明确,a次一定是给同一个生物放大的。但是至于是对哪一个生物放大,还是要用暴力一个一个去找,而不要对排序后第一个值操作;

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iterator>
#include <cmath>
using namespace std; #define lson (l , mid , rt << 1)
#define rson (mid + 1 , r , rt << 1 | 1)
#define debug(x) cerr << #x << " = " << x << "\n";
#define pb push_back #define Pll pair<ll,ll>
#define Pii pair<int,int> #define fi first
#define se second #define OKC ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef unsigned long long ull; /*-----------------show time----------------*/
const int maxn = 2e5+;
int a,b,n;
struct node {
ll h,d;
ll w;
}t[maxn];
const ll inf = 0x3f3f3f3f3f3f3f3f;
int main(){
OKC;
cin>>n>>a>>b;
for(int i=; i<=n; i++)
{
cin>>t[i].h>>t[i].d;
t[i].w = t[i].h - t[i].d;
if(t[i].w<)t[i].w = ;
}
ll sum = ;
sort(t+,t++n,[](node a,node b){return a.w>b.w;});
for(int i=; i<=n; i++)
{
if(i<=b)sum += max (t[i].h,t[i].d);
else sum += t[i].d;
}
ll ans = sum;
if(b==)cout<<ans<<endl;
else
{
for(int i=; i<=n; i++)
{
ll tmp = sum;
if(i<=b)
{
tmp -= max(t[i].h,t[i].d);
tmp += 1ll*(t[i].h<<a);
}
else
{
tmp -= t[i].d;
tmp += 1ll*(t[i].h<<a);
tmp += t[b].d;
tmp -= max(t[b].d,t[b].h);
}
if(ans<tmp)ans = tmp;
}
cout<<ans<<endl;
} return ;
}

CF976E

Educational Codeforces Round 43 E&976E. Well played! 贪心的更多相关文章

  1. Educational Codeforces Round 43

    Educational Codeforces Round 43  A. Minimum Binary Number 显然可以把所有\(1\)合并成一个 注意没有\(1\)的情况 view code / ...

  2. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

  3. Educational Codeforces Round 43 E. Well played!(贪心)

    E. Well played! time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  4. Educational Codeforces Round 43 (Rated for Div. 2) ABCDE

    A. Minimum Binary Number time limit per test 1 second memory limit per test 256 megabytes input stan ...

  5. Educational Codeforces Round 7 E. Ants in Leaves 贪心

    E. Ants in Leaves 题目连接: http://www.codeforces.com/contest/622/problem/E Description Tree is a connec ...

  6. C. Brutality Educational Codeforces Round 59 (Rated for Div. 2) 贪心+思维

    C. Brutality time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  7. C. Playlist Educational Codeforces Round 62 (Rated for Div. 2) 贪心+优先队列

    C. Playlist time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...

  8. [Educational Codeforces Round 16]E. Generate a String

    [Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...

  9. [Educational Codeforces Round 16]D. Two Arithmetic Progressions

    [Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...

随机推荐

  1. 【译】尝试使用Nullable Reference Types

    随着.NET Core 3.0 Preview 7的发布,C#8.0已被认为是“功能完整”的.这意味着它们的最大亮点Nullable Reference Types,在行为方面也被锁定在.NET Co ...

  2. 高性能MySQL之基础架构

    一.背景 为什么我们需要先学习MYSQL的基础架构先呢? 原因很简单,当我们需要了解一件事物的时候,我们只有站在宏观的层面,才能层层剥丝抽茧的去理解问题.举个例子,我们要看一个框架的源码,一开始就想进 ...

  3. 【POJ - 2236】Wireless Network (并查集)

    Wireless Network 这接翻译了 Descriptions 地震发生在东南亚.ACM(亚洲合作医疗团队)已经与膝上电脑建立了无线网络,但是一次意外的余震袭击,网络中的所有计算机都被打破了. ...

  4. 通过wireshark学习Traceroute命令和mtr(UDP,ICMP协议)

    traceroute: 通过TTL限定的ICMP/UDP/TCP侦测包来发现从本地主机到远端目标主机之间的第三层转发路径.用来调试网络连接性和路由问题. mtr: traceroute的一个变种,能根 ...

  5. bio,nio,aio学习

    http://qindongliang.iteye.com/blog/2018539 1 同步 指的是用户进程触发IO操作并等待或者轮询的去查看IO操作是否就绪 自己上街买衣服,自己亲自干这件事,别的 ...

  6. 初识JavaScript和面向对象

    1.javascript基本数据类型: number: 数值类型 string: 字符串类型 boolean: 布尔类型 null: 空类型 undefault:未定义类型 object: 基本数据类 ...

  7. 阿里架构师浅析Java设计模式之虚拟代理模式

    虚拟代理模式(Virtual Proxy)是一种节省内存的技术,它建议创建那些占用大量内存或处理复杂的对象时,把创建这类对象推迟到使用它的时候.在特定的应用中,不同部分的功能由不同的对象组成,应用启动 ...

  8. 洛谷 P1196 [NOI2002]银河英雄传说

    题意简述 有30000列,每列都有一艘战舰,编号1~30000 有2种操作: 1.将一列的战舰运到另一列 2.询问两个战舰是否在同一列,如果是,求出它们之间的距离 题解思路 并查集, 维护每个点x离自 ...

  9. linux之压缩和解压

    归档:也称为打包,指的是一个文件或目录的集合,而这个集合被存储在一个文件中.归档文件没有经过压缩,因此,它占用的空间是其中所有文件和目录的总和.压缩:压缩文件也是一个文件和目录的集合,且这个集合也被存 ...

  10. [Spring cloud 一步步实现广告系统] 21. 系统错误汇总

    广告系统学习过程中问题答疑 博客园 Eureka集群启动报错 Answer 因为Eureka在集群启动过程中,会连接集群中其他的机器进行数据同步,在这个过程中,如果别的服务还没有启动完成,就会出现Co ...