传送门: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. java多线程核心api以及相关概念(一)

    这篇博客总结了对线程核心api以及相关概念的学习,黑体字可以理解为重点,其他的都是我对它的理解 个人认为这些是学习java多线程的基础,不理解熟悉这些,后面的也不可能学好滴 目录 1.什么是线程以及优 ...

  2. 【iOS】tableView:cellForRowAtIndexPath: 方法未调用

    今天遇到这个问题, UITableView 的代理方法 tableView:cellForRowAtIndexPath: - (UITableViewCell *)tableView:(UITable ...

  3. 使用Java 编写FTP中的长传文件和下载文件

    实现FTP文件上传与下载可以通过以下两种种方式实现(不知道还有没有其他方式,),分别为:1.通过JDK自带的API实现:2.通过Apache提供的API是实现. 第一种方法:通过JDK自带的API实现 ...

  4. 如何在Vue项目中使用vw实现移动端适配

    有关于移动端的适配布局一直以来都是众说纷纭,对应的解决方案也是有很多种.在< 使用Flexible实现手淘H5页面的终端适配>提出了Flexible的布局方案,随着 viewport 单位 ...

  5. Windows的 IIS 部署django项目

    Windows的 IIS 部署django项目 1.安装Windows的IIS 功能(win10为例): (1)进入控制面板  :选择大图标    进入程序和功能 (2)启用或者关闭Windows功能 ...

  6. Cobbler 自动安装CentOS7

    1. Cobbler介绍 Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装.重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等.Cobbler可以使用命 ...

  7. 自己动手写Spring框架--IOC、MVC

    对于一名Java开发人员,我相信没有人不知道 Spring 框架,而且也能够轻松就说出 Spring 的特性-- IOC.MVC.AOP.ORM(batis). 下面我想简单介绍一下我写的轻量级的 S ...

  8. java并发编程(十五)----(线程池)java线程池简介

    好的软件设计不建议手动创建和销毁线程.线程的创建和销毁是非常耗 CPU 和内存的,因为这需要 JVM 和操作系统的参与.64位 JVM 默认线程栈是大小1 MB.这就是为什么说在请求频繁时为每个小的请 ...

  9. 利用hash或history实现单页面路由

    目录 html代码 css代码 JavaScript代码 hash方式 history 方式 浏览器端代码 服务器端 在chrome(版本 70.0.3538.110)测试正常 编写涉及:css, h ...

  10. Linux(CentOS7)下RabbitMQ下载安装教程

    原文链接:http://www.studyshare.cn/software/details/1172/0 一.下载安装步骤 下载erlang 1.wget 下载地址 2.rpm -Uvh erlan ...