题目链接:Doors Breaking and Repairing

题目大意:有n个门,先手攻击力为x(摧毁),后手恢复力为y(恢复),输入每个门的初始“生命值”,当把门的生命值攻为0时,就无法恢复了。问:最多可以把几个门的生命值攻为0

思路:(1)当 x>y 的时候肯定所有的门的生命值都能降为0

   (2)当 x<=y 的时候,先手的最优策略就是每次去攻击那些当前“生命值”比自己攻击力小的门,使它们的生命值降为0;

     后手的最优策略就是去提高那些“生命值”比先手小的门的“生命值”,来减少先手“攻破”的门的数量,

     那些“生命值”本来就比先手攻击力高的先手就更攻破不了了;所以直接用门的“”生命值”小于等于x的门的个数除以2向上取整即可。

 /* */
# include <bits/stdc++.h>
using namespace std;
typedef long long ll; ll a[];
int main()
{
int n, x, y, num=, sum=;
cin>>n>>x>>y;
for(int i=; i<=n; i++ )
{
cin>>a[i];
if( a[i]<=x )
sum++;
}
if( x<=y )
cout<<ceil(sum/2.0)<<endl;
else
cout<<n<<endl;
return ;
}

Doors Breaking and Repairing的更多相关文章

  1. Doors Breaking and Repairing CodeForces - 1102C (思维)

    You are policeman and you are playing a game with Slavik. The game is turn-based and each turn consi ...

  2. Codeforce 1102 C. Doors Breaking and Repairing

    Descirbe You are policeman and you are playing a game with Slavik. The game is turn-based and each t ...

  3. Codeforces Round #531 (Div. 3) C. Doors Breaking and Repairing (博弈)

    题意:有\(n\)扇门,你每次可以攻击某个门,使其hp减少\(x\)(\(\le 0\)后就不可修复了),之后警察会修复某个门,使其hp增加\(y\),问你最多可以破坏多少扇门? 题解:首先如果\(x ...

  4. Codeforces Round #531 (Div. 3) ABCDEF题解

    Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...

  5. Reinvent the Wheel Often

    Reinvent the Wheel Often Jason P. Sage Just use something that exists-it's silly to reinvent the whe ...

  6. How can I protect derived classes from breaking when I change the internal parts of the base class?

    How can I protect derived classes from breaking when I change the internal parts of the base class? ...

  7. poj 1556 The Doors

    The Doors Time Limit: 1000 MS Memory Limit: 10000 KB 64-bit integer IO format: %I64d , %I64u   Java ...

  8. POJ 1556 The Doors(线段交+最短路)

    The Doors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5210   Accepted: 2124 Descrip ...

  9. poj 3216 Repairing Company(最短路Floyd + 最小路径覆盖 + 构图)

    http://poj.org/problem?id=3216 Repairing Company Time Limit: 1000MS   Memory Limit: 131072K Total Su ...

随机推荐

  1. SpringCloud微服务基础学习

    看了蚂蚁课堂的微服务学习,确实学习了不少关于微服务的知识,现在总结学习如下 : SpringCloud微服务基础单点系统架构传统项目架构传统项目分为三层架构,将业务逻辑层.数据库访问层.控制层放入在一 ...

  2. java之mybatis之一对多关联映射

    1.在一对多的关联映射中,表结构如下 2.实体类结构 User.java public class User implements Serializable{ private int id; priv ...

  3. Function.prototype.apply.call 理解分析

    首先需要了解apply,call的基本用法,其目的是改变调用方法中的this指向,将其指向为传入的对象,改变this的指向,两种方法接收参数的方式不同. 代码:console.log var cons ...

  4. JAVA项目之注册

    public class RegisterServlet extends HttpServlet { private UsersService usersService = new UsersServ ...

  5. synchronized关键字的使用

    synchronized关键字是java并发编程中常使用的同步锁,用于锁住方法或者代码块,锁代码块时可以是synchronized(this){}.synchronized(Object){}.syn ...

  6. java static变量及函数

    java以类为基础,没有游离在类之外单独存在的变量.所以,c++中的全局变量,在java中应该是不存在的.java中有的是成员变量和成员方法.当成员前以static修饰时,即为静态成员变量或静态成员方 ...

  7. ES读写索引内幕分析

    一.简介 ES中的索引都进行分片,每个分片都会保存多个副本.这些副本称为复制组,在添加或删除索引时必须同步副本.如果不这样,从不同的副本中读取的索引可能截然不同.保持分片副本同步并从中提供读取的过程被 ...

  8. java开发手册-总结与补充

    1.分层领域模型规约 1.DO( Data Object):与数据库表结构一一对应,通过 DAO 层向上传输数据源对象. 2.DTO( Data Transfer Object):数据传输对象, Se ...

  9. 【BBED】编译及基本命令(1)

    [BBED]编译及基本命令(1) 一.1  BLOG文档结构图       一.2  前言部分   一.2.1  导读和注意事项 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你 ...

  10. docker 常见问题处理汇总

    问题一: docker执行docker info出现如下警告WARNING: bridge-nf-call-iptables is disabledWARNING: bridge-nf-call-ip ...